Example #1
0
    void Update()
    {
        if (rotateFocus)
        {
            Rotate();
        }

        if (drag == true && oldDrag != drag)
        {
            collide.enabled = false;
            foreach (SpriteRenderer sprites in childRenderers)
            {
                sprites.sortingLayerID = 1;
            }
        }
        else if (drag == false && oldDrag != drag)
        {
            collide.enabled = true;
            if (OnGame())
            {
                foreach (SpriteRenderer sprites in childRenderers)
                {
                    sprites.sortingLayerID = 3;
                }
            }
            else
            {
                foreach (SpriteRenderer sprites in childRenderers)
                {
                    sprites.sortingLayerID = 0;
                }
            }
        }

        if (drag == true)
        {
            SnapToCenter();
            SmoothScaleUp();
        }
        else if (!drag && OnGame())
        {
            if (ScaleToManager() && !inStack)
            {
                inStack = true;
                cm.AddToStack(this);
                foreach (SpriteRenderer sprites in childRenderers)
                {
                    sprites.sortingLayerID = 0;
                }
            }
        }
        else if (!drag && !OnGame())
        {
            SmoothScaleDown();
            OverlappingOnDesk();
        }
        oldDrag = drag;
    }