示例#1
0
 public static void DrawPorts(XNode.Node target)
 {
     EditorGUILayout.BeginHorizontal();
     NodeEditorGUILayout.PortField(new GUIContent("Input"), target.GetInputPort("input"), GUILayout.MinWidth(0));
     NodeEditorGUILayout.PortField(new GUIContent("Output"), target.GetOutputPort("output"), GUILayout.MinWidth(0));
     EditorGUILayout.EndHorizontal();
 }
示例#2
0
 void Start()
 {
     // Create a copy of the behaviour tree so we can indivudually set values
     behaviourTree = (BehaviourTree)behaviourTree.Copy();
     XNode.Node entry = ((BehaviourTree)behaviourTree.Copy()).FindEntryNode();
     behaviourTreeRoot = (BehaviourNode)entry.GetOutputPort("child").GetConnection(0).node;
     behaviourTreeRoot.Reset();
 }
示例#3
0
        public static void DrawOutputs(XNode.Node target, SerializedObject serializedObject)
        {
            NodePort outputPort = target.GetOutputPort("output");

            serializedObject.FindProperty("outputFoldout").boolValue = EditorGUILayout.Foldout(serializedObject.FindProperty("outputFoldout").boolValue, "Outputs [" + outputPort.ConnectionCount + "]", true);
            bool outputFoldout = serializedObject.FindProperty("outputFoldout").boolValue;

            GUIStyle labelStyle  = new GUIStyle(EditorStyles.label);
            GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton);

            labelStyle.wordWrap = true;

            if (outputFoldout)
            {
                for (int i = 0; i < outputPort.ConnectionCount; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    NodePort outputConnectionPort = outputPort.GetConnection(i);
                    Node     outputConnectionNode = outputPort.GetConnection(i).node;

                    if (outputConnectionNode is State)
                    {
                        string label = outputConnectionNode.name;
                        label = label.Replace("\n", "");
                        label = label.Substring(0, Mathf.Min(32, label.Length));
                        EditorGUILayout.LabelField(string.Format("[{0}] {1}", "Answer", label, labelStyle));
                    }

                    if (GUILayout.Button("^", GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
                    {
                        if (i <= 0)
                        {
                            return;
                        }

                        outputPort.SwitchConnections(i, i - 1);
                    }

                    if (GUILayout.Button("v", GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)))
                    {
                        if (i >= outputPort.ConnectionCount - 1)
                        {
                            return;
                        }

                        outputPort.SwitchConnections(i, i + 1);
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
        }