少年修仙传客户端基础资源
lwb
2020-12-15 72e89391ca4fc27f3b67c3fa3616f29a106317d5
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, October 31, 2017
//--------------------------------------------------------
using UnityEngine;
using UnityEditor;
using System.Collections;
using UnityEngine.UI;
using Snxxz.UI;
 
 
public class PrefabCreateTool
{
    [MenuItem("GameObject/UI/UIRoot")]
    public static UIRoot CreateUIRoot()
    {
        var uiroot = GameObject.FindObjectOfType<UIRoot>();
        if (uiroot == null)
        {
            var prefab = BuiltInLoader.LoadPrefab("UIRoot");
            var root = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity);
            root.name = "UIRoot";
            uiroot = root.GetComponent<UIRoot>();
        }
        return uiroot;
    }
 
    public static void SetParent(GameObject instance, Transform parent = null)
    {
        if (instance == null)
            return;
        // var uiroot = CreateUIRoot();
        if (parent == null)
            if (Selection.transforms != null && Selection.transforms.Length > 0)
            {
                parent = Selection.transforms[0];
            }
        // else
        // {
        //     parent = uiroot.normalCanvas.transform;
        // }
        instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one);
        // PrefabUtility.DisconnectPrefabInstance(instance);
        Selection.activeGameObject = instance;
    }
 
    public static GameObject LoadUIPattern(string name)
    {
        return AssetDatabase.LoadAssetAtPath<GameObject>(string.Format("Assets/Editor/UIPattern/{0}.prefab", name));
    }
 
    [MenuItem("GameObject/UI/FunctionButton")]
    public static void CreateFunctionButton()
    {
        var instance = UIUtility.CreateWidget("FunctionButtonPattern", "FunctionButton");
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/GeneralWin_1")]
    public static void CreateWindowPattern1()
    {
        var prefab = LoadUIPattern("GeneralWin");
        var instance = GameObject.Instantiate(prefab) as GameObject;
        instance.name = "GeneralWin";
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/RewardGroup")]
    public static void CreateRewardGroup()
    {
        var prefab = LoadUIPattern("Container_Rewards");
        var instance = GameObject.Instantiate(prefab) as GameObject;
        instance.name = "Container_Rewards";
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/CommonItemCell")]
    public static void CreateCommonItemCell()
    {
        var prefab = LoadUIPattern("CommonItemCell");
        var instance = GameObject.Instantiate(prefab) as GameObject;
        instance.name = "CommonItemCell";
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/SortTable")]
    public static void CreateSortTable()
    {
        var prefab = LoadUIPattern("SortTable");
        var instance = GameObject.Instantiate(prefab) as GameObject;
        instance.name = "SortTable";
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/TextEx")]
    public static void CreateTextEx()
    {
        var instance = new GameObject("TextEx");
        instance.AddComponent<TextEx>();
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/ImageEx")]
    public static void CreateImageEx()
    {
        var instance = new GameObject("ImageEx");
        instance.AddComponent<ImageEx>();
        SetParent(instance);
    }
 
    [MenuItem("GameObject/UI/通用按钮")]
    public static void CreateButtonEx()
    {
        var button = UIUtility.CreateWidget("CommonButton", "CommonButton");
        SetParent(button);
    }
 
    [MenuItem("GameObject/UI/SecondFrameLoad")]
    public static void CreateSecondFrameLoad()
    {
        var prefab = LoadUIPattern("SecondFrameLoad");
        var instance = GameObject.Instantiate(prefab) as GameObject;
        instance.name = "SecondFrameLoad";
        SetParent(instance);
    }
 
 
}