#if !COMBAT_SERVER

using System;
using UnityEngine;
using UnityEngine.Rendering;

namespace Fort23.Mono
{
    public class RenderSetting : MonoBehaviour
    {
        private Renderer Renderer;
        public string SortingLayerName;
        public int order;


        public void OnValidate()
        {
            if (!Application.isPlaying)
            {
                SetOrder(order, SortingLayerName);
            }
        }


        public void SetOrder(int order, string layer)
        {
            this.order = order;
            if (Renderer == null)
            {
                Renderer = GetComponent<Renderer>();
            }

            if (Renderer == null)
            {
                return;
            }

            Renderer.sortingLayerName = layer;
            Renderer.sortingOrder = order;
        }
    }
}

#endif