Ejemplo n.º 1
0
                private bool DrawEditConditionsButtons(int index)
                {
                    ConditionalState conditionalState = (ConditionalState)GetEditableObject();
                    bool             changedArray     = false;

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(20.0f));
                    {
                        if (GUILayout.Button("\u25b2") && index > 0)
                        {
                            ConditionalStateBranch condition = conditionalState._branches[index];
                            ArrayUtils.Remove(ref conditionalState._branches, index);
                            ArrayUtils.Insert(ref conditionalState._branches, condition, index - 1);
                            changedArray = true;
                        }
                        else if (GUILayout.Button("\u25bc") && index < conditionalState._branches.Length - 1)
                        {
                            ConditionalStateBranch condition = conditionalState._branches[index];
                            ArrayUtils.Remove(ref conditionalState._branches, index);
                            ArrayUtils.Insert(ref conditionalState._branches, condition, index + 1);
                            changedArray = true;
                        }
                        else if (GUILayout.Button("Remove"))
                        {
                            ArrayUtils.Remove(ref conditionalState._branches, index);
                            changedArray = true;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.Separator();

                    return(changedArray);
                }
Ejemplo n.º 2
0
                private static string GetConditionLabel(ConditionalStateBranch condition, bool firstBranch)
                {
                    string description = "<b>" + condition.GetDescription() + "</b>, then go to <b>" + condition._goToState + "</b>";

                    if (!firstBranch)
                    {
                        description = "Else " + description;
                    }

                    return(description);
                }
Ejemplo n.º 3
0
            public override StateMachineEditorLink[] GetEditorLinks()
            {
                if (_branches != null)
                {
                    StateMachineEditorLink[] links = new StateMachineEditorLink[_branches.Length];

                    for (int i = 0; i < _branches.Length; i++)
                    {
                        ConditionalStateBranch branch = _branches[i];
                        links[i] = new StateMachineEditorLink(branch, "goToState", branch.GetTakenText());
                    }

                    return(links);
                }

                return(null);
            }
Ejemplo n.º 4
0
                private bool DrawAddConditionButton()
                {
                    EditorGUILayout.BeginHorizontal(GUILayout.Width(20.0f));
                    {
                        if (GUILayout.Button("Add New Condition"))
                        {
                            ConditionalState       conditionalState = (ConditionalState)GetEditableObject();
                            ConditionalStateBranch newCondition     = new ConditionalStateBranch();
                            ArrayUtils.Add(ref conditionalState._branches, newCondition);

                            StateMachineEditor editor = (StateMachineEditor)GetEditor();
                            editor.OnAddedNewObjectToTimeline(newCondition);

                            return(true);
                        }

                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();

                    return(false);
                }