Beispiel #1
0
                private bool DrawAddBackgroundLogicButton()
                {
                    int index = 0;

                    Type[] logicTypes = SystemUtils.GetAllSubTypes(typeof(ConditionalStateBackgroundLogic));

                    string[] logicTypeNames = new string[logicTypes.Length + 1];
                    logicTypeNames[index++] = "(Add State Background Logic)";

                    foreach (Type type in logicTypes)
                    {
                        logicTypeNames[index] = type.Name;
                        index++;
                    }

                    int newIndex = EditorGUILayout.Popup(string.Empty, 0, logicTypeNames);

                    if (0 != newIndex)
                    {
                        Type branchType = logicTypes[newIndex - 1];

                        ConditionalStateBackgroundLogic newBackgroundLogic = Activator.CreateInstance(branchType) as ConditionalStateBackgroundLogic;
                        ConditionalState conditionalState = (ConditionalState)GetEditableObject();

                        ArrayUtils.Add(ref conditionalState._backgroundLogic, newBackgroundLogic);

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

                        return(true);
                    }

                    return(false);
                }
Beispiel #2
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);
                }