Exemple #1
0
        /// <summary>
        /// Class constructor.
        /// <param name="stateTransition">The target transition.</param>
        /// <param name="destination">The target destination.</param>
        /// <param name="index">The transition index.</param>
        /// <param name="blackboard">The state blackboard.</param>
        /// </summary>
        public TransitionGUI (StateTransition stateTransition, InternalStateBehaviour destination, int index, InternalBlackboard blackboard) {
            m_Transition = stateTransition;
            m_Destination = destination;

            // It's a global event?
            if (m_Transition.eventID < 0) {
                 if (InternalGlobalBlackboard.Instance != null)
                     m_FsmEvent = InternalGlobalBlackboard.Instance.GetFsmEvent(m_Transition.eventID);
            }
            // It's a local variable and the blackboard is not null?
            else if (m_Transition.eventID > 0 && blackboard != null)
                m_FsmEvent = blackboard.GetFsmEvent(m_Transition.eventID);

            // Get the transition arrow vertical offset
            m_VerticalOffset = StateGUI.defaultHeight + TransitionGUI.defaultHeight * (index + .35f);
        }
Exemple #2
0
        /// <summary>
        /// Removes the transition from the state.
        /// <param name="state">The state that owns the target transition.</param>
        /// <param name="transition">The transition to  be removed.</param>
        /// </summary>
        public static void RemoveTransition (InternalStateBehaviour state, StateTransition transition) {
            // Validate members
            if (state != null && transition != null) {
                // Register undo
                #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                Undo.RegisterUndo (state, "Delete Transition");
                #else
                Undo.RecordObject (state, "Delete Transition");
                #endif

                // Remove transition
                state.RemoveTransition(transition);

                // Set state dirty flag
                EditorUtility.SetDirty(state);
            }
        }
Exemple #3
0
        /// <summary>
        /// Sets a new destination state to the supplied transition.
        /// <param name="state">The state that owns the target transition.</param>
        /// <param name="transition">The transition to set the new destination.</param>
        /// <param name="destination">The new destination state.</param>
        /// </summary>
        public static void SetNewDestination (InternalStateBehaviour state, StateTransition transition, InternalStateBehaviour destination) {
            // Validate members
            if (state != null && transition != null) {
                // Register undo
                #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                Undo.RegisterUndo(state,"Transition Destination");
                #else
                Undo.RecordObject(state,"Transition Destination");
                #endif

                // Create a connection to the destination
                transition.destination = destination;

                // Set state dirty flag
                EditorUtility.SetDirty(state);
            }
        }
Exemple #4
0
        /// <summary>
        /// Sets a new event id in the supplied transition.
        /// <param name="state">The state that owns the target transition.</param>
        /// <param name="transition">The transition to set the new event id.</param>
        /// <param name="eventId">The new event id.</param>
        /// </summary>
        public static void SetNewEvent (InternalStateBehaviour state, StateTransition transition, int eventId) {
            // Validate members
            if (state != null && transition != null) {
                // Register undo
                #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                Undo.RegisterUndo (state, "Transition Event");
                #else
                Undo.RecordObject (state, "Transition Event");
                #endif

                // Set transition event
                transition.eventID = eventId;

                // Set state dirty flag
                EditorUtility.SetDirty(state);
            }
        }
 /// <summary> 
 /// Clears everything stored in the drag & drop.
 /// </summary>
 public static void AcceptDrag () {
     s_CandidateForDrag = null;
     s_TransitionGUI = null;
     s_Dragging = null;
     s_StateGUI = null;
 }
 /// <summary> 
 /// Initiates a drag operation using the candidateForDrag transition supplied by PrepareStartDrag.
 /// </summary>
 public static void StartDrag () {
     s_Dragging = s_CandidateForDrag.transition;
     s_TransitionGUI = s_CandidateForDrag;
     s_CandidateForDrag = null;
 }
        // public static StateTransition dragged;

        #region Methods

        /// <summary> 
        /// Clears the current dragging transition and prepares for initiating a drag operation.
        /// <param name="transitionGUI">The transition gui candidate for dragging. You can access it later using the candidateForDrag property.</param>
        /// <param name="guiState">The StateGUI that has the transitionGui.</param>
        /// </summary>
        public static void PrepareStartDrag (TransitionGUI transitionGUI, StateGUI guiState) {
            s_CandidateForDrag = transitionGUI;
            s_StateGUI = guiState;
            s_Dragging = null;
        }
 /// <summary> 
 /// Function to fire onTransitionPerformed event in subclasses.
 /// <param name="transition">The transition that was performed.</param>
 /// </summary>
 #if UNITY_EDITOR
 protected void OnTransition (StateTransition transition) {
     if (onTransitionPerformed != null)
         onTransitionPerformed(transition);
 }
        /// <summary> 
        /// Removes a transition.
        /// <param name="transition">The transition to be removed.</param>
        /// </summary>
        public void RemoveTransition (StateTransition transition) {
            var transitionList = new List<StateTransition>(m_Transitions);
            if (transitionList.Contains(transition)) {
                transitionList.Remove(transition);
                m_Transitions = transitionList.ToArray();
            }

        }
 /// <summary> 
 /// Adds a new transition.
 /// <param name="eventID">The event id of the new transition.</param>
 /// <returns>The created transition.</returns>
 /// </summary>
 public StateTransition AddTransition (int eventID) {
     var transitionList = new List<StateTransition>(m_Transitions);
     var transition = new StateTransition();
     transition.eventID = eventID;
     transitionList.Add(transition);
     m_Transitions = transitionList.ToArray();
     return transition;
 }