void OnEnable() { NodeGraphComponent nodeGraphComponent = (NodeGraphComponent)target; _unscaledTime = serializedObject.FindProperty("_unscaledTime"); _runInEditor = serializedObject.FindProperty("_runInEditor"); _nodeGraphRef = serializedObject.FindProperty("_nodeGraphRef"); _nodeGraphRefAsset = _nodeGraphRef.FindPropertyRelative("_file"); _floatInputs = serializedObject.FindProperty("_floatInputs"); _intInputs = serializedObject.FindProperty("_intInputs"); _floatRangeInputs = serializedObject.FindProperty("_floatRangeInputs"); _intRangeInputs = serializedObject.FindProperty("_intRangeInputs"); _vector2Inputs = serializedObject.FindProperty("_vector2Inputs"); _vector3Inputs = serializedObject.FindProperty("_vector3Inputs"); _vector4Inputs = serializedObject.FindProperty("_vector4Inputs"); _quaternionInputs = serializedObject.FindProperty("_quaternionInputs"); _colorInputs = serializedObject.FindProperty("_colorInputs"); _stringInputs = serializedObject.FindProperty("_stringInputs"); _boolInputs = serializedObject.FindProperty("_boolInputs"); _gradientInputs = serializedObject.FindProperty("_gradientInputs"); _animationCurveInputs = serializedObject.FindProperty("_animationCurveInputs"); _transformInputs = serializedObject.FindProperty("_transformInputs"); _gameObjectInputs = serializedObject.FindProperty("_gameObjectInputs"); _componentInputs = serializedObject.FindProperty("_componentInputs"); _materialInputs = serializedObject.FindProperty("_materialInputs"); _textureInputs = serializedObject.FindProperty("_textureInputs"); if (nodeGraphComponent.GetNodeGraph() == null) { nodeGraphComponent.LoadNodeGraph(); } _nodeGraph = nodeGraphComponent.GetNodeGraph(); }
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(); }