public static void OpenWindow(LogicComponentType componentType, ComponentObjectBase components, LogicComponentBase value = null, string componetPathName = "") { instance = GetWindow <SelectLogicObjectEditor>(); instance.position = new Rect(Screen.width / 2, Screen.height / 2, 500, 500); instance.value = value; instance.components = components; if (value == null) { instance.isNew = true; } instance.Init(componentType, componetPathName); }
private void DrawNameAndClassListGUI(string name, ComponentObjectBase componentObject, LogicComponentType triggerType) { List <LogicComponentBase> dataList = componentObject.GetLogicComs(); GUILayout.Space(6); GUIStyle style = "flow overlay header lower left"; GUILayout.BeginHorizontal(style); GUILayout.Label(name); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.Width(30))) { SelectLogicObjectEditor.OpenWindow(triggerType, componentObject); } GUILayout.EndHorizontal(); GUILayout.BeginVertical("box"); for (int i = 0; i < dataList.Count; i++) { LogicComponentBase value = dataList[i]; GUILayout.BeginHorizontal(); string menuName = ""; ComponentNameAttribute cccc = CompontNameAttributeUtils.GetCompontNameAttributeByClassName(value.GetType().FullName); if (cccc != null) { menuName = cccc.menuName; } GUILayout.Label(" " + menuName); GUILayout.Label(value.ToExplain()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Edit")) { SelectLogicObjectEditor.OpenWindow(triggerType, componentObject, dataList[i], menuName); } if (GUILayout.Button("-", GUILayout.Width(55))) { if (EditorUtility.DisplayDialog("提示", "你要删除当前组件吗?", "是", "否")) { dataList.RemoveAt(i); componentObject.SaveComponentDataToClassValue(); } return; } if (GUILayout.Button("▲", GUILayout.Width(55))) { if (i - 1 >= 0) { LogicComponentBase temps = dataList[i]; dataList.RemoveAt(i); dataList.Insert(i - 1, temps); } return; } if (GUILayout.Button("复制", GUILayout.Width(55))) { if (copyDataDic.ContainsKey(triggerType)) { copyDataDic[triggerType] = value; } else { copyDataDic.Add(triggerType, value); } } if (copyDataDic.ContainsKey(triggerType)) { if (GUILayout.Button("粘贴", GUILayout.Width(55))) { dataList[i] = copyDataDic[triggerType]; copyDataDic.Remove(triggerType); } } GUILayout.EndHorizontal(); GUILayout.Space(6); } GUILayout.EndVertical(); }