public void SortCompLayerChange(Consts.DrawLayers newLayer, Transform newParent)
    {
        currParent = transform.parent = newParent;
        LayerSortComp.LayerChange(newLayer, true);
        SendChangeToTracker();

        // TODO: Should also have a version that changes the layer order
        // Possibly one that specifies whether to change the sprite renderer or sorting group specifically, but this is fine for now.
    }
    protected void CheckChangeZDepth()
    {
        Consts.DrawLayers layerToCheck = GetTopLayerInLineage();

        // Adjust z depth based around water, which is always at z = 0, and is not a sprite
        if (layerToCheck >= Consts.DrawLayers.Water)
        {
            Utility.RepositionZ(sprite.gameObject.transform, (float)Consts.ZLayers.FrontOfWater);
        }
        else
        {
            Utility.RepositionZ(sprite.gameObject.transform, (float)Consts.ZLayers.BehindWater);
        }
    }
    public void LayerChange(Consts.DrawLayers newLayer, bool resetGroupParent)
    {
        GroupParent.RemoveFromGroupList(this);

        if (resetGroupParent)
        {
            SetGroupParent();
        }

        DrawLayerCurr = newLayer;
        CheckChangeZDepth();

        GroupParent.AddToGroupList(this);
    }
    public virtual Consts.DrawLayers GetTopLayerInLineage()
    {
        Consts.DrawLayers retLayer = DrawLayerCurr;

        Transform transParent = sprite.transform.parent;

        while (transParent != null)
        {
            if (transParent.GetComponent <SortingGroup>() != null)
            {
                retLayer = transParent.GetComponent <SpriteBase>().SGRef.DrawLayerCurr;
            }
            transParent = transParent.parent;
        }

        return(retLayer);
    }
 public void SortCompLayerChange(Consts.DrawLayers newLayer)
 {
     LayerSortComp.LayerChange(newLayer, false);
     SendChangeToTracker();
 }
 public SortingGroupComponentRef(SpriteBase sprite, SortingGroup sgComp, Consts.DrawLayers drawLayerOrig) : base(sprite, drawLayerOrig)
 {
     comp         = sgComp;
     comp.enabled = true;
 }
 public SpriteLayerComponentData(SpriteBase sprite, Consts.DrawLayers drawLayerOrig)
 {
     DrawLayerOrig = drawLayerCurr = drawLayerOrig;
     this.sprite   = sprite;
 }
 public SpriteLayerComponentData()
 {
     drawLayerCurr = Consts.DrawLayers.Default;
 }
 public SpriteRendererComponentRef(SpriteBase sprite, SpriteRenderer comp, SortingGroupComponentRef sgCompRef, Consts.DrawLayers drawLayerOrig) : base(sprite, drawLayerOrig)
 {
     this.comp = comp;
     if (sgCompRef != null)
     {
         sgCompRef.AddToGroupList(this);
     }
 }