public override void OnInspectorGUI() { transition = (Transition)target; EditorGUI.BeginChangeCheck(); var fromName = transition.fromState.GetStatePreview(); var toName = transition.targetInfo; var displayName = fromName + "->" + toName; EGL.LabelField(displayName); EGL.Space(); FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect); EGL.Space(); transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType); if (transition.triggerRangeType == TriggerRangeType.Range) { transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange); } if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore) { transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec); } transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer); using (new EGL.VerticalScope(EditorStyles.helpBox)) { var conds = transition.conditions; var paramNames = transition.profile.parameters.Select(it => it.name).ToArray(); using (new EGL.HorizontalScope()) { EGL.LabelField("Conditions", EditorStyles.boldLabel); GL.FlexibleSpace(); if (GL.Button("+", GL.Width(30))) { conds.Add(new Condition()); } } for (int i = 0; i < conds.Count; ++i) { var cond = conds[i]; EGL.BeginHorizontal(); int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name)); // cond.name = EGL.TextField(cond.name, GL.Width(70)); condSelectIndex = EGL.Popup(condSelectIndex, paramNames); cond.name = paramNames[condSelectIndex]; var param = transition.profile.FindParam(cond.name); if (param == null) { EGL.LabelField("!Doesn't exist"); } else { var type = param.type; if (type == ParamType.Bool) { cond.boolValue = EGL.Toggle(cond.boolValue); } else if (type != ParamType.Trigger) // Trigger 不需要编辑 { cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50)); if (type == ParamType.Int) { cond.intValue = EGL.IntField(cond.intValue); } else { cond.floatValue = EGL.FloatField(cond.floatValue); } } } GL.FlexibleSpace(); if (GL.Button("-", GL.Width(30))) { conds.RemoveAt(i); --i; } EGL.EndHorizontal(); } } EGL.LabelField("", GUI.skin.horizontalSlider); transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType); if (transition.actionType == ActionType.ChangeState) { EGL.BeginHorizontal(); EGL.PrefixLabel("Target State"); EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames, str => transition.targetStateName = str, ref targetStateRect); transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30)); EGL.LabelField("F", GUILayout.Width(20)); var targetState = transition.profile.FindState(transition.targetStateName); if (targetState) { if (GL.Button("Focus")) { Utils.FocusEditingAnimation(transition.profile, targetState.stateName); } } EGL.EndHorizontal(); if (!targetState) { EGL.HelpBox("No target state " + targetState, MessageType.Error); } } else // SendMessage { transition.messageName = EGL.TextField("Message Name", transition.messageName); EGL.Space(); transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType); switch (transition.messageParType) { case MessageParType.Int: transition.messageParInt = EGL.IntField("Value", transition.messageParInt); break; case MessageParType.Float: transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat); break; case MessageParType.Bool: transition.messageParBool = EGL.Toggle("Value", transition.messageParBool); break; } } transition.priority = EGL.IntField("Priority", transition.priority); transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay); if (transition.shouldDelay) { transition.delay = EGL.FloatField("Delay", transition.delay); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(transition); } if (transition.fromState.type == FromStateType.State) { EGL.LabelField("", GUI.skin.horizontalSlider); using (new EGL.VerticalScope(EditorStyles.helpBox)) { EGL.LabelField("From State", EditorStyles.boldLabel); ++EditorGUI.indentLevel; var fromState = transition.profile.FindState(transition.fromState.stateOrTagName); if (fromState) { GUI.enabled = false; if (!fromStateEditor || fromStateEditor.target != fromState) { if (fromStateEditor) { DestroyImmediate(fromStateEditor); } fromStateEditor = Editor.CreateEditor(fromState); } fromStateEditor.OnInspectorGUI(); GUI.enabled = true; } --EditorGUI.indentLevel; } } }