yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
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
50
51
52
53
54
55
56
57
58
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>();
                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);
            }
        }
    }
 
 
}