void Init(LogicComponentType componentType, string componetPathName) { logicComponetType = componentType; string logicFileUseType = ""; if (StateMachineEditorWindow.Instance) { logicFileUseType = LogicSystemEditorWindow.logicFileUseType; } componetNameArr = CompontNameAttributeUtils.GetCompontNameAttributeArray(componentType, logicFileUseType); if (isNew == false) { for (int i = 0; i < componetNameArr.Length; i++) { if (componetNameArr[i] == componetPathName) { selectInt0 = i; return; } } } }
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(); }
void OnGUI() { if (componetNameArr.Length == 0) { return; } GUILayout.Space(15); GUILayout.BeginHorizontal(); selectInt0 = EditorGUILayout.Popup(logicComponetType.ToString(), selectInt0, componetNameArr); GUILayout.EndHorizontal(); GUILayout.Space(15); ComponentNameAttribute tn = CompontNameAttributeUtils.GetCompontNameAttribute(logicComponetType, componetNameArr[selectInt0]); value = (LogicComponentBase)GetInstance(tn.className, value); Type extendEditorType = EditorExtendAttributeUtils.GetEditorExtendType(typeof(EditorExtendBase), value.GetType());// GetEditorExtendType(value.GetType()); if (extendEditorType != null) { if (editorExtendClassNameValue == null || editorExtendClassNameValue.GetType() != extendEditorType) { if (editorExtendClassNameValue != null) { editorExtendClassNameValue.OnClose(); } editorExtendClassNameValue = (EditorExtendBase)Activator.CreateInstance(extendEditorType); editorExtendClassNameValue.target = value; editorExtendClassNameValue.OnAwak(); } editorExtendClassNameValue.EditorOverrideClassGUI(); } else { if (editorExtendClassNameValue != null) { editorExtendClassNameValue.OnClose(); } LogicSystemAttributeEditorGUI.DrawInternalVariableGUI(value); } GUILayout.Space(15); if (value != null) { //Debug.Log(" ValueType :" + value.GetType() + " baseType:" + value.GetType().BaseType); GUILayout.Label(((LogicComponentBase)value).ToExplain()); } GUILayout.Space(15); GUILayout.BeginHorizontal(); if (GUILayout.Button("确定", GUILayout.Width(120))) { if (isNew) { components.GetLogicComs().Add(value); } components.SaveComponentDataToClassValue(); Close(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("取消", GUILayout.Width(120))) { Close(); } GUILayout.EndHorizontal(); }