Change children objects.

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);

        }
    }
}

layerOrd.sortingOrder is an int, and you’re using int.equals, which is a comparison function… and you are comparing it to a gameobject?

what are you trying to achieve with this? set it to the same sortingorder as the gameobject?

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.