| | |
| | | using UnityEditor; |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | using Snxxz.UI; |
| | | using vnxbqy.UI; |
| | | |
| | | |
| | | public class PrefabCreateTool |
| | |
| | | { |
| | | if (instance == null) |
| | | return; |
| | | var uiroot = CreateUIRoot(); |
| | | // var uiroot = CreateUIRoot(); |
| | | if (parent == null) |
| | | if (Selection.transforms != null && Selection.transforms.Length > 0) |
| | | { |
| | | parent = Selection.transforms[0]; |
| | | } |
| | | else |
| | | { |
| | | parent = uiroot.normalCanvas.transform; |
| | | } |
| | | // 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() |
| | |
| | | [MenuItem("GameObject/UI/GeneralWin_1")] |
| | | public static void CreateWindowPattern1() |
| | | { |
| | | var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/GeneralWin.prefab"); |
| | | 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 = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/Container_Rewards.prefab"); |
| | | 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 = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/CommonItemCell.prefab"); |
| | | 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 = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/SortTable.prefab"); |
| | | var prefab = LoadUIPattern("SortTable"); |
| | | var instance = GameObject.Instantiate(prefab) as GameObject; |
| | | instance.name = "SortTable"; |
| | | SetParent(instance); |
| | |
| | | SetParent(instance); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/ButtonEx")] |
| | | [MenuItem("GameObject/UI/通用按钮")] |
| | | public static void CreateButtonEx() |
| | | { |
| | | var button = new GameObject("ButtonEx"); |
| | | var btnEx = button.AddComponent<ButtonEx>(); |
| | | var imgEx = button.AddComponent<ImageEx>(); |
| | | btnEx.targetGraphic = imgEx; |
| | | var button = UIUtility.CreateWidget("CommonButton", "CommonButton"); |
| | | SetParent(button); |
| | | var text = new GameObject("TextEx"); |
| | | text.AddComponent<TextEx>(); |
| | | SetParent(text, button.transform); |
| | | } |
| | | |
| | | [MenuItem("GameObject/UI/SecondFrameLoader")] |
| | | public static void CreateSecondFrameLoader() |
| | | [MenuItem("GameObject/UI/红点")] |
| | | public static void CreateRedPoint() |
| | | { |
| | | var go = new GameObject("SecondFrameLoader"); |
| | | go.AddComponent<SecondFrameLoader>(); |
| | | SetParent(go); |
| | | var button = UIUtility.CreateWidget("RedPoint", "RedPoint"); |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |
| | | |