Esempio n. 1
0
    /// <summary>
    /// Draws all the elements inside the <see cref="TransitionGUI"/>
    /// </summary>
    public override void DrawWindow()
    {
        switch (sender.currentElem.GetType().ToString())
        {
        case nameof(FSM):
            DefaultPerceptionEditor();
            break;

        case nameof(BehaviourTree):
            if (isExit)
            {
                DefaultPerceptionEditor();
            }
            else
            {
                // If the parent node is a non-random sequence we add an index selector
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUILayout.Label("Order:", Styles.CenteredTitleText, GUILayout.Width(30), GUILayout.Height(20));
                GUILayout.Space(5);
                if (GUILayout.Button(((BehaviourNode)toNode).index.ToString(), EditorStyles.toolbarDropDown))
                {
                    GenericMenu toolsMenu = new GenericMenu();

                    for (int i = 1; i <= ((BehaviourTree)sender.currentElem).ChildrenCount((BehaviourNode)fromNode); i++)
                    {
                        int newId = i;

                        toolsMenu.AddItem(new GUIContent(i.ToString()), false, () =>
                        {
                            if (newId != ((BehaviourNode)toNode).index)
                            {
                                NodeEditorUtilities.GenerateUndoStep(sender.currentElem);
                                ((BehaviourNode)fromNode).ReorderIndices((BehaviourNode)toNode, newId);
                                ((BehaviourNode)toNode).index = newId;
                            }
                        });
                    }

                    toolsMenu.DropDown(new Rect(0, Event.current.mousePosition.y, 0, 0));
                    EditorGUIUtility.ExitGUI();
                }
                GUILayout.EndHorizontal();
            }
            break;

        case nameof(UtilitySystem):
            if (isExit)
            {
                DefaultPerceptionEditor();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(15);
                GUILayout.Label("Weight:", Styles.CenteredTitleText, GUILayout.Width(20), GUILayout.Height(25));

                // Check if the user changes the textArea
                float.TryParse(EditorGUILayout.TextField(weight.ToString(CultureInfo.CreateSpecificCulture("en-US")), Styles.CenteredTitleText,
                                                         GUILayout.ExpandWidth(true), GUILayout.Height(25)), NumberStyles.Any, CultureInfo.CreateSpecificCulture("en-US"), out weight);

                GUILayout.EndHorizontal();
            }
            break;
        }
    }