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