Ejemplo n.º 1
0
 //detects any trigger with objects with tag and change the layer to display at the back ob the sprite
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Chair" || collision.tag == "Walls" || collision.tag == "Tables")
     {
         FurnitureObstacles fO = collision.GetComponent <FurnitureObstacles>();
         if (furnitureO.Count == 0 || fO.MySpriteRender.sortingOrder - 1 < parentRenderer.sortingOrder)
         {
             parentRenderer.sortingOrder = fO.MySpriteRender.sortingOrder - 1;
         }
         furnitureO.Add(fO);
     }
 }
Ejemplo n.º 2
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == "Chair" || collision.tag == "Walls" || collision.tag == "Tables")
     {
         FurnitureObstacles fO = collision.GetComponent <FurnitureObstacles>();
         furnitureO.Remove(fO);
         if (furnitureO.Count == 0)
         {
             parentRenderer.sortingOrder = 300;
         }
         else
         {
             furnitureO.Sort();
             parentRenderer.sortingOrder = furnitureO[0].MySpriteRender.sortingOrder - 1;
         }
     }
 }