private void CreateWindowContextMenu(IDSMState a_State) { m_ContextMenu = new GenericMenu(); m_ContextMenu.AddItem(new GUIContent("Add/Transition"), false, AddTransition, a_State); m_ContextMenu.AddItem( new GUIContent("Delete/'" + a_State.displayName + "'"), false, RemoveState, a_State); if (a_State.transitions.Count == 0) { return; } foreach (var transition in a_State.transitions) { m_ContextMenu.AddItem( new GUIContent("Delete/Transition/" + "'" + transition.displayName + "'"), false, RemoveTransition, transition); } }
public void RemoveState(IDSMState a_State) { if (!EditorUtility.DisplayDialog( "Warning!", "Are you sure you want to delete this state?", "Yes", "No")) { return; } DestroyImmediate(a_State as Object, true); }
public static bool IsAllowedTransition(this IDSMState a_From, IDSMState a_To) { if (a_From.maxTransitions != -1 && a_From.transitions.Count >= a_From.maxTransitions) { return(false); } if (a_To.maxTransitions != -1 && a_To.transitions.Count >= a_To.maxTransitions) { return(false); } if ((a_To.allowedTransitionTypes & AllowedTransitionType.To) == 0) { return(false); } if ((a_From.allowedTransitionTypes & AllowedTransitionType.From) == 0) { return(false); } switch (a_From.attribute) { case StateAttribute.Exit: case StateAttribute.FromAny: case StateAttribute.Entry: { if ((a_To.allowedTransitionTypes & AllowedTransitionType.FromSpecial) == 0) { return(false); } } break; } switch (a_To.attribute) { case StateAttribute.Exit: case StateAttribute.FromAny: case StateAttribute.Entry: { if ((a_From.allowedTransitionTypes & AllowedTransitionType.ToSpecial) == 0) { return(false); } } break; } return(true); }
public IDSMTransition AddTransition(IDSMState a_Other) { if (!this.IsAllowedTransition(a_Other)) { return(null); } var newTransition = m_Parent.AddChildAsset <DSMTransition> (); newTransition.Init(m_Parent, this, a_Other as DSMState); var other = a_Other as DSMState; other.AddToTransition(newTransition); m_FromTransitions.Add(newTransition); return(newTransition); }