public static IngameUIViewTools CheckHasUIViewTools(this Transform t) { IngameUIViewTools tool = t.GetComponent <IngameUIViewTools>(); if (tool == null) { Debug.LogError("预制体:" + t.name + " 没有手动添加IngameUIViewTools组件,请事后手动添加(目前自动动态添加仅在运行时)"); tool = t.gameObject.AddComponent <IngameUIViewTools>(); tool.FindAllGameObejct(); } return(tool); }
public override void OnInspectorGUI() { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("点击拷贝生成变量定义代码", GUILayout.Height(30.0f))) { GUIUtility.systemCopyBuffer = CopyVarCreateMessage(); } if (GUILayout.Button("点击拷贝生成变量赋值代码", GUILayout.Height(30.0f))) { GUIUtility.systemCopyBuffer = CopyVarSetValueMessage(); } EditorGUILayout.EndHorizontal(); GUI.color = Color.green; if (GUILayout.Button("点击拷贝所有代码实现(自带Awake)", GUILayout.Height(30.0f))) { GUIUtility.systemCopyBuffer = GetVarAllCode(); } GUI.color = Color.white; EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("手动添加key-value:"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Key:", GUILayout.Width(40.0f)); inputKey = EditorGUILayout.TextField(inputKey); EditorGUILayout.LabelField("Object:", GUILayout.Width(40.0f)); inputObject = EditorGUILayout.ObjectField(inputObject, typeof(GameObject)) as GameObject; if (inputObject != null) { inputKey = inputObject.name; } if (GUILayout.Button("Add")) { view.AddObHandItem(inputKey, inputObject); SaveAll(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("点击自动获取所有子物体", GUILayout.Height(30.0f))) { view.FindAllGameObejct(); SaveAll(); } EditorGUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("清空自动添加数据", GUILayout.Height(30.0f))) { ClearAutoData(); SaveAll(); } if (GUILayout.Button("清空手动添加数据", GUILayout.Height(30.0f))) { ClearHandData(); SaveAll(); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); obHandDicTarget = EditorGUILayout.Foldout(obHandDicTarget, "以下为所有主动添加key-value:"); if (obHandDicTarget) { ShowDicData(view.objHandKeyLists, view.objHandLists); } obDicTarget = EditorGUILayout.Foldout(obDicTarget, "以下为所有自动添加key-value:"); if (obDicTarget) { ShowDicData(view.objKeyLists, view.objLists); } EditorGUILayout.EndVertical(); }