Beispiel #1
0
        void DrawInspector()
        {
            var constant = GraphHelper.SelectedNode as NodeConstant;

            var selectedType = NodeEditorPropertiesHelper.DrawTypeField(constant.ValueWrapper.ValueType, GraphHelper.GraphType, NodePinTypeCategory.Constant);

            constant.SetType(selectedType.WrappedType);

            NodeEditorPropertiesHelper.DrawValueWrapperField(constant.ValueWrapper);
        }
        void DrawVariable(NodeGraphVariable variable)
        {
            if (!_variableViewStates.ContainsKey(variable))
            {
                return;
            }

            var foldOut = _variableViewStates[variable].Foldout;

            _variableViewStates[variable].Foldout = EditorGUILayout.Foldout(foldOut, variable.Name);

            if (foldOut)
            {
                EditorGUI.indentLevel++;

                EditorGUILayout.BeginVertical();

                variable.ReplacementName = EditorGUILayout.DelayedTextField("Name", variable.Name);
                NodeEditorPropertiesHelper.DrawTypeField(variable, GraphHelper.GraphType);
                NodeEditorPropertiesHelper.DrawValueWrapperField(variable.WrappedValue);

                EditorGUILayout.BeginHorizontal();

                GUILayout.Label("Spawn");

                if (GUILayout.Button("Get"))
                {
                    SpawnNodeFromFocusedVariable(variable, NodeGraphVariableAccessorType.Get);
                }

                if (GUILayout.Button("Get Set"))
                {
                    SpawnNodeFromFocusedVariable(variable, NodeGraphVariableAccessorType.GetSet);
                }

                if (GUILayout.Button("Set"))
                {
                    SpawnNodeFromFocusedVariable(variable, NodeGraphVariableAccessorType.Set);
                }

                EditorGUILayout.EndHorizontal();

                // Remove
                if (GUILayout.Button("Remove"))
                {
                    bool doRemoveAction = true;
                    var  hasReferences  = GraphHelper.GetNodesByVariableReference(variable).Count != 0;

                    if (hasReferences)
                    {
                        doRemoveAction = EditorUtility.DisplayDialog("Warning",
                                                                     "Nodes in the graph are referencing this variable. Are you sure you want to continue?",
                                                                     "Yes",
                                                                     "No");
                    }

                    if (doRemoveAction)
                    {
                        RemoveVariable.InvokeSafe(new RemoveGraphVariableEvent(variable));
                    }
                }

                EditorGUILayout.EndVertical();

                EditorGUI.indentLevel--;
            }
        }