yyl
1 天以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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);
            }
        }
    }
 
 
}