using System.Collections; using System.Collections.Generic; using Cysharp.Threading.Tasks; using UnityEngine; [RequireComponent(typeof(RectTransform))] public class SpringDecorate : MonoBehaviour { [SerializeField] int m_SortOrder = 0; GameObject springDecorate = null; private async void Start() { if (GeneralDefine.UISpringDecorate != 0) { if (springDecorate == null) { springDecorate = await UIUtility.CreateWidget("Container_SpringDecorate", "SpringDecorate"); if (this == null || springDecorate == null) { if (null != springDecorate) { DestroyImmediate(springDecorate); } return; } } var rectTransform = springDecorate.transform as RectTransform; rectTransform.MatchWhith(this.transform as RectTransform); if (m_SortOrder != 0) { var canvas = this.AddMissingComponent(); canvas.overrideSorting = true; canvas.sortingLayerName = "UI"; canvas.sortingOrder = m_SortOrder; } else { var canvas = this.GetComponent(); if (canvas != null) { DestroyImmediate(canvas); } } } else { if (springDecorate != null) { GameObject.DestroyImmediate(springDecorate); } } } }