using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
[ExecuteAlways]
|
public class RenderOrder : MonoBehaviour
|
{
|
public int order = 10000;
|
|
[ExecuteAlways]
|
private void OnEnable()
|
{
|
LayerUtility.SetLayer(this.gameObject, LayerUtility.UILayer, true);
|
Renderer[] renders = this.GetComponentsInChildren<Renderer>(true);
|
for (int i = 0; i < renders.Length; i++)
|
{
|
var render = renders[i];
|
render.sortingLayerName = "UI";
|
render.sortingOrder = order;
|
}
|
}
|
|
}
|