| | |
| | | |
| | | public class PrefabCreateTool |
| | | { |
| | | |
| | | [MenuItem("GameObject/UI/FunctionButton")] |
| | | public static void CreateFunctionButton() |
| | | { |
| | | var instance = UIUtility.CreateWidget("FunctionButtonPattern", "FunctionButton"); |
| | | if (instance != null) |
| | | [MenuItem("GameObject/UI/UIRoot")] |
| | | public static UIRoot CreateUIRoot() |
| | | { |
| | | var uiroot = GameObject.FindObjectOfType<UIRoot>(); |
| | | if (uiroot == null) |
| | |
| | | root.name = "UIRoot"; |
| | | uiroot = root.GetComponent<UIRoot>(); |
| | | } |
| | | return uiroot; |
| | | } |
| | | |
| | | Transform parent = null; |
| | | 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]; |
| | |
| | | { |
| | | parent = uiroot.normalCanvas.transform; |
| | | } |
| | | |
| | | instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | PrefabUtility.DisconnectPrefabInstance(instance); |
| | | // PrefabUtility.DisconnectPrefabInstance(instance); |
| | | Selection.activeGameObject = instance; |
| | | } |
| | | |
| | | |
| | | [MenuItem("GameObject/UI/FunctionButton")] |
| | | public static void CreateFunctionButton() |
| | | { |
| | | var instance = UIUtility.CreateWidget("FunctionButtonPattern", "FunctionButton"); |
| | | SetParent(instance); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/GeneralWin_1")] |
| | |
| | | var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/GeneralWin.prefab"); |
| | | var instance = GameObject.Instantiate(prefab) as GameObject; |
| | | instance.name = "GeneralWin"; |
| | | |
| | | if (instance != null) |
| | | { |
| | | var uiroot = GameObject.FindObjectOfType<UIRoot>(); |
| | | if (uiroot == null) |
| | | { |
| | | var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); |
| | | var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); |
| | | root.name = "UIRoot"; |
| | | uiroot = root.GetComponent<UIRoot>(); |
| | | } |
| | | |
| | | Transform 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; |
| | | } |
| | | SetParent(instance); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/RewardGroup")] |
| | |
| | | var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/Container_Rewards.prefab"); |
| | | var instance = GameObject.Instantiate(prefab) as GameObject; |
| | | instance.name = "Container_Rewards"; |
| | | |
| | | if (instance != null) |
| | | { |
| | | var uiroot = GameObject.FindObjectOfType<UIRoot>(); |
| | | if (uiroot == null) |
| | | { |
| | | var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); |
| | | var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); |
| | | root.name = "UIRoot"; |
| | | uiroot = root.GetComponent<UIRoot>(); |
| | | } |
| | | |
| | | Transform 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; |
| | | } |
| | | SetParent(instance); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/CommonItemCell")] |
| | |
| | | var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/CommonItemCell.prefab"); |
| | | var instance = GameObject.Instantiate(prefab) as GameObject; |
| | | instance.name = "CommonItemCell"; |
| | | |
| | | if (instance != null) |
| | | { |
| | | var uiroot = GameObject.FindObjectOfType<UIRoot>(); |
| | | if (uiroot == null) |
| | | { |
| | | var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); |
| | | var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); |
| | | root.name = "UIRoot"; |
| | | uiroot = root.GetComponent<UIRoot>(); |
| | | } |
| | | |
| | | Transform 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; |
| | | } |
| | | |
| | | SetParent(instance); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/SortTable")] |
| | |
| | | var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/SortTable.prefab"); |
| | | var instance = GameObject.Instantiate(prefab) as GameObject; |
| | | instance.name = "SortTable"; |
| | | |
| | | if (instance != null) |
| | | { |
| | | var uiroot = GameObject.FindObjectOfType<UIRoot>(); |
| | | if (uiroot == null) |
| | | { |
| | | var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); |
| | | var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); |
| | | root.name = "UIRoot"; |
| | | uiroot = root.GetComponent<UIRoot>(); |
| | | SetParent(instance); |
| | | } |
| | | |
| | | Transform parent = null; |
| | | if (Selection.transforms != null && Selection.transforms.Length > 0) |
| | | [MenuItem("GameObject/UI/TextEx")] |
| | | public static void CreateTextEx() |
| | | { |
| | | parent = Selection.transforms[0]; |
| | | } |
| | | else |
| | | { |
| | | parent = uiroot.normalCanvas.transform; |
| | | var instance = new GameObject("TextEx"); |
| | | instance.AddComponent<TextEx>(); |
| | | SetParent(instance); |
| | | } |
| | | |
| | | instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); |
| | | PrefabUtility.DisconnectPrefabInstance(instance); |
| | | Selection.activeGameObject = instance; |
| | | [MenuItem("GameObject/UI/ImageEx")] |
| | | public static void CreateImageEx() |
| | | { |
| | | var instance = new GameObject("ImageEx"); |
| | | instance.AddComponent<ImageEx>(); |
| | | SetParent(instance); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/ButtonEx")] |
| | | public static void CreateButtonEx() |
| | | { |
| | | var button = new GameObject("ButtonEx"); |
| | | var btnEx = button.AddComponent<ButtonEx>(); |
| | | var imgEx = button.AddComponent<ImageEx>(); |
| | | btnEx.targetGraphic = imgEx; |
| | | SetParent(button); |
| | | var text = new GameObject("TextEx"); |
| | | text.AddComponent<TextEx>(); |
| | | SetParent(text, button.transform); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/SecondFrameLoader")] |
| | | public static void CreateSecondFrameLoader() |
| | | { |
| | | var go = new GameObject("SecondFrameLoader"); |
| | | go.AddComponent<SecondFrameLoader>(); |
| | | SetParent(go); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |