using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SortingLayerChanger : MonoBehaviour
{
    public string LayerName;
    public int LayerOrder;

    [ContextMenu("Set Layers")]
    public void SetLayers()
    {
        Renderer rend = GetComponent<Renderer>();
        rend.sortingLayerName = LayerName;
        rend.sortingOrder = LayerOrder;
    }

    public IEnumerator Start()
    {
        Renderer rend;
        while ((rend = GetComponent<Renderer>()) == null)
            yield return null;
        SetLayers();
    }
}
