示例#1
0
        /// <inheritdoc />
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            DrawDefaultInspector();

            if (GUILayout.Button("Edit Dialog Tree"))
            {
                NodeGraphEditorWindow.CreateNewWindow(target as IDialogSpeaker);
            }
        }
                private static void CreateWindow()
                {
                    // Get existing open window or if none, make a new one:
                    _instance = (NodeGraphEditorWindow)GetWindow(typeof(NodeGraphEditorWindow), false, kWindowWindowName);

                    if (_instance._nodeGraphEditor == null || _instance._nodeGraphEditor.GetEditorWindow() == null)
                    {
                        _instance._nodeGraphEditor = NodeGraphEditor.CreateInstance <NodeGraphEditor>();
                        _instance._nodeGraphEditor.Init(kWindowTitle, _instance, kWindowTag);
                    }
                }
                public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
                {
                    EditorGUI.BeginProperty(position, label, property);

                    Rect foldoutPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

                    property.isExpanded = EditorGUI.Foldout(foldoutPosition, property.isExpanded, property.displayName);
                    _height             = EditorGUIUtility.singleLineHeight;

                    if (property.isExpanded)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;

                        Rect filePosition = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width, EditorGUIUtility.singleLineHeight);

                        SerializedProperty fileProp = property.FindPropertyRelative("_file");
                        fileProp.objectReferenceValue = EditorGUI.ObjectField(filePosition, "File", fileProp.objectReferenceValue, typeof(TextAsset), true);

                        _height += EditorGUIUtility.singleLineHeight;

                        if (fileProp.objectReferenceValue != null)
                        {
                            Rect editButtonPosition = new Rect(position.x + EditorGUIUtility.labelWidth, position.y + EditorGUIUtility.singleLineHeight * 2, (position.width - EditorGUIUtility.labelWidth), EditorGUIUtility.singleLineHeight);

                            if (GUI.Button(editButtonPosition, "Edit"))
                            {
                                NodeGraphEditorWindow.Load(fileProp.objectReferenceValue as TextAsset);
                            }
                            _height += EditorGUIUtility.singleLineHeight;
                        }

                        EditorGUI.indentLevel = origIndent;
                    }

                    EditorGUI.EndProperty();
                }
示例#4
0
                public override void OnInspectorGUI()
                {
                    EditorGUILayout.PropertyField(_unscaledTime);
                    {
                        _nodeGraphRefFoldOut = EditorGUILayout.Foldout(_nodeGraphRefFoldOut, "Node Graph");

                        if (_nodeGraphRefFoldOut)
                        {
                            int origIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel++;

                            EditorGUI.BeginChangeCheck();

                            EditorGUILayout.PropertyField(_nodeGraphRefAsset);

                            if (EditorGUI.EndChangeCheck())
                            {
                                SyncInputNodes(new Node[0]);
                                serializedObject.ApplyModifiedProperties();
                                ReloadNodeGraph();
                            }

                            if (!_nodeGraphRefAsset.hasMultipleDifferentValues)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    EditorGUILayout.LabelField(GUIContent.none, GUILayout.Width(EditorUtils.GetLabelWidth()));

                                    if (GUILayout.Button("Edit"))
                                    {
                                        NodeGraphEditorWindow.Load(_nodeGraphRefAsset.objectReferenceValue as TextAsset);
                                    }
                                    else if (GUILayout.Button("Refresh"))
                                    {
                                        ReloadNodeGraph();
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }

                            EditorGUI.indentLevel = origIndent;
                        }
                    }

                    if (_nodeGraph != null && !_nodeGraphRefAsset.hasMultipleDifferentValues)
                    {
                        _inputsFoldOut = EditorGUILayout.Foldout(_inputsFoldOut, "Inputs");

                        if (_inputsFoldOut)
                        {
                            int origIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel++;

                            Node[] inputNodes = _nodeGraph.GetInputNodes();
                            SyncInputNodes(inputNodes);

                            foreach (Node inputNode in inputNodes)
                            {
                                RenderInputNode(inputNode);
                            }

                            EditorGUI.indentLevel = origIndent;
                        }

                        _outputsFoldOut = EditorGUILayout.Foldout(_outputsFoldOut, "Outputs");

                        if (_outputsFoldOut)
                        {
                            int origIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel++;

                            Node[]             outputNodes;
                            NodeGraphComponent nodeGraphComponent = (NodeGraphComponent)target;

                            //Is the application is running then get the output node directly from the component so can see the live value
                            if (Application.isPlaying && nodeGraphComponent.GetOutputNodes() != null)
                            {
                                outputNodes = nodeGraphComponent.GetOutputNodes();
                            }
                            else
                            {
                                outputNodes = _nodeGraph.GetOutputNodes();
                            }

                            foreach (Node outputNode in outputNodes)
                            {
                                RenderOutputNode(outputNode);
                            }

                            EditorGUI.indentLevel = origIndent;
                        }
                    }

                    serializedObject.ApplyModifiedProperties();
                }
                public override void OnInspectorGUI()
                {
                    NodeGraphComponent nodeGraphComponent = (NodeGraphComponent)target;

                    EditorGUILayout.PropertyField(_unscaledTime);

                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(_runInEditor);
                        if (EditorGUI.EndChangeCheck() && _runInEditor.boolValue)
                        {
                            nodeGraphComponent.LoadNodeGraph();
                            _nodeGraph = nodeGraphComponent.GetNodeGraph();
                        }
                    }

                    {
                        _nodeGraphRefOut = EditorGUILayout.Foldout(_nodeGraphRefOut, "Node Graph");

                        if (_nodeGraphRefOut)
                        {
                            int origIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel++;

                            EditorGUI.BeginChangeCheck();

                            EditorGUILayout.PropertyField(_nodeGraphRefAsset);

                            if (EditorGUI.EndChangeCheck())
                            {
                                SyncInputNodes(new Node[0]);
                                serializedObject.ApplyModifiedProperties();
                                nodeGraphComponent.LoadNodeGraph();
                                _nodeGraph = nodeGraphComponent.GetNodeGraph();
                            }

                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField(GUIContent.none, GUILayout.Width(EditorGUIUtility.labelWidth - (EditorGUI.indentLevel * 15.0f) + 11));

                                if (GUILayout.Button("Edit"))
                                {
                                    NodeGraphEditorWindow.Load(_nodeGraphRefAsset.objectReferenceValue as TextAsset);
                                }
                                else if (GUILayout.Button("Refresh"))
                                {
                                    nodeGraphComponent.LoadNodeGraph();
                                    _nodeGraph = nodeGraphComponent.GetNodeGraph();
                                }
                            }
                            EditorGUILayout.EndHorizontal();

                            EditorGUI.indentLevel = origIndent;
                        }
                    }

                    if (_nodeGraph != null)
                    {
                        _inputsFoldOut = EditorGUILayout.Foldout(_inputsFoldOut, "Inputs");

                        if (_inputsFoldOut)
                        {
                            int origIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel++;

                            Node[] inputNodes = _nodeGraph.GetInputNodes();

                            //First sync nodes with objects in _inputObjects
                            SyncInputNodes(inputNodes);

                            RenderInputArray(nodeGraphComponent, _floatInputs, ref _floatsInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _intInputs, ref _intInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _floatRangeInputs, ref _floatRangeInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _intRangeInputs, ref _intRangeInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _vector2Inputs, ref _vector2InputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _vector3Inputs, ref _vector3InputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _vector4Inputs, ref _vector4InputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _quaternionInputs, ref _quaternionInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _colorInputs, ref _colorInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _stringInputs, ref _stringInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _boolInputs, ref _boolInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _gradientInputs, ref _gradientInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _animationCurveInputs, ref _animationCurveInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _transformInputs, ref _transformInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _gameObjectInputs, ref _gameObjectInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _componentInputs, ref _componentInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _materialInputs, ref _materialInputsFoldOut);
                            RenderInputArray(nodeGraphComponent, _textureInputs, ref _textureInputsFoldOut);

                            EditorGUI.indentLevel = origIndent;
                        }
                    }

                    serializedObject.ApplyModifiedProperties();
                }