// ** Bullshit required because Unity is such a load of garbage. ** public virtual void InactiveAwake() { if (awakeRan) { return; } sgRef = null; if (GetComponent <SortingGroup>() != null) { sgRef = new SortingGroupComponentRef(this, GetComponent <SortingGroup>()); } srRef = new SpriteRendererComponentRef(this, GetComponent <SpriteRenderer>(), sgRef); RefShape = GetComponent <RefShape>(); // Get whatever parent sprite group data is available origParent = baseParent = currParent = transform.parent; //origPos = transform.position; selectable = false; awakeRan = true; }
public bool IsChildOf(SortingGroupComponentRef sgRef) { if (sprite.SGRef == sgRef) { return(true); } Transform transParent = sprite.transform.parent; while (transParent != null) { if (transParent.GetComponent <SortingGroup>() != null) { if (transParent.GetComponent <SpriteBase>().SGRef == sgRef) { return(true); } } transParent = transParent.parent; } // No need to check DrawLayerMngr.topSortGroup of course, as it does not exist on screen. return(false); }
public SpriteRendererComponentRef(SpriteBase sprite, SpriteRenderer comp, SortingGroupComponentRef sgCompRef, Consts.DrawLayers drawLayerOrig) : base(sprite, drawLayerOrig) { this.comp = comp; if (sgCompRef != null) { sgCompRef.AddToGroupList(this); } }
public virtual void SetGroupParent() { GroupParent = null; Transform transParent = sprite.transform.parent; while (transParent != null) { if (transParent.GetComponent <SortingGroup>() != null) { GroupParent = transParent.GetComponent <SpriteBase>().SGRef; return; } transParent = transParent.parent; } if (GroupParent == null) { GroupParent = DrawLayerMngr.topSortGroup; } }
// Set up once time per game public static void Init() { if (initialized) { return; } topSortGroup = new SortingGroupComponentRef(); sortingLayers = new Dictionary <Consts.DrawLayers, string>(); foreach (Consts.DrawLayers drawLayer in Enum.GetValues(typeof(Consts.DrawLayers))) { sortingLayers.Add(drawLayer, drawLayer.ToString()); } initialized = true; // TODO: Erase when no longer needed //debugTextBox1 = GameObject.Find("DebugDisp1").GetComponent<Text>(); //debugTextBox2 = GameObject.Find("DebugDisp2").GetComponent<Text>(); }
public SpriteRendererComponentRef(SpriteBase sprite, SpriteRenderer comp, SortingGroupComponentRef sgCompRef) : this(sprite, comp, sgCompRef, (Consts.DrawLayers)Enum.Parse(typeof(Consts.DrawLayers), comp.sortingLayerName)) { }