I am working on a little script that changes the sortingLayer of child objects, but it does not seem to be working.
Here is my script if someone could help me that would be great:
using UnityEngine;
using System.Collections;
public class ChangeChildren : MonoBehaviour {
public GameObject GetSl;
void OnInspectorUpdate(){
GetSl.GetComponent<SpriteRenderer>();
}
public void ChangeKidsLayer(){
foreach(SpriteRenderer layerOrd in GetComponentsInChildren<SpriteRenderer>()) {
layerOrd.sortingOrder.Equals(GetSl);
}
}
}
Yes I am trying to get all of the children objects under the gameobject to have the same sortingOrder as the parent object.
I am trying to compare to the GetSL (GetSortingLayer) gameobject to take the sortingOrder from that object and set the Layer int from GetSL to all of the children objects.