Beispiel #1
0
    // Use this for initialization
    IEnumerator Start()
    {
        yield return(null);

        //GameObjectsToSort = FindGameObjectsWithLayer(SL);

        //GameObjectsToSort = FindGameObjectsWithObject();


        LSOY = FindObjectsOfType <layerSortOnY>();


        foreach (layerSortOnY LS in LSOY)
        {
            //	if (LS.SortOnUpdate) {

            try {
                //GO.GetComponentInChildren<SpriteRenderer>().sortingOrder = Mathf.RoundToInt(transform.position.y * 100f) * -1;

                int idealOrder = Mathf.RoundToInt(LS.transform.position.y * 100f) * -1;

                LS.ReorderSprites(idealOrder);
            } catch {
            }
            //}
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        foreach (layerSortOnY LS in LSOY)
        {
            try {
                //GO.GetComponentInChildren<SpriteRenderer>().sortingOrder = Mathf.RoundToInt(transform.position.y * 100f) * -1;

                int idealOrder = Mathf.RoundToInt(LS.transform.position.y * 100f) * -1;

                LS.ReorderSprites(idealOrder);
            } catch {
            }
        }
    }