public EditorNode(NodeBasedEditor editor, BaseCutsceneNode actualNode, Vector2 position, GUIStyle headerStyle, GUIStyle boxStyle) { rect = new Rect(position.x, position.y, 140, 20); this.editor = editor; this.actualNode = actualNode; this.headerStyle = headerStyle; this.boxStyle = boxStyle; previousActualNodePosition = actualNode.transform.position; }
private BaseCutsceneNode GetOutputSlot(string label) { BaseCutsceneNode node = null; if (outputNodeLabels.Contains(label)) { int targetIndex = outputNodeLabels.IndexOf(label); if (outputNodes.Count > targetIndex) { node = outputNodes[targetIndex]; } } return(node); }
private void OnClickAddNode(Vector2 mousePosition, Type type, Dictionary <string, object> data = null) { //Actually adding it to the scene GameObject actualObject = new GameObject(); Undo.RegisterCreatedObjectUndo(actualObject, "create cutscene node"); BaseCutsceneNode actualNode = Undo.AddComponent(actualObject, type).GetComponent <BaseCutsceneNode>(); actualNode.cutsceneManager = cutsceneManager; actualNode.transform.SetParent(cutsceneManager.transform); actualNode.transform.position = cutsceneManager.transform.position; actualNode.name = "New " + type.Name; EditorNode node = new EditorNode(this, actualNode, mousePosition, headerStyle, nodeStyle) { OnRemoveNode = OnClickRemoveNode }; node.PrepareConnections(inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint); nodes.Add(actualNode, node); node.SyncEditorNodePosition(); }
public override void OnInspectorGUI() { if (outputLinkMode) { GUILayout.Label("Please press the button on the node in the scene view you want to link to " + node.outputNodeLabels[linkableOutputSlotIndex] + ".", EditorStyles.wordWrappedLabel); } else { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Options"); if (GUILayout.Button("Set as start node") && node.cutsceneManager.startNode != node) { Undo.RecordObject(node, "set start node"); node.cutsceneManager.startNode = node; } if (GUILayout.Button("Select cutscene manager")) { Selection.SetActiveObjectWithContext(node.cutsceneManager.gameObject, null); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); showOutputs = EditorGUILayout.Foldout(showOutputs, "Outputs"); if (GUILayout.Button("Refresh slots")) { node.ReloadOutputs(); } EditorGUILayout.EndHorizontal(); if (showOutputs) { SerializedProperty sp = serializedObject.FindProperty("outputNodes"); if (sp.isArray) { int arrayLength = 0; sp.Next(true); // skip generic field sp.Next(true); // advance to array size field arrayLength = sp.intValue; sp.Next(true); // loop through all serialized properties and create a property field for each one int lastIndex = arrayLength - 1; for (int i = 0; i < arrayLength; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(sp, new GUIContent(node.outputNodeLabels[i]), null); if (GUILayout.Button("Link")) { outputLinkMode = true; linkableOutputSlotNodeBackup = node.outputNodes[i]; SceneView.onSceneGUIDelegate += DrawFloatingButtons; if (SceneView.lastActiveSceneView) { SceneView.lastActiveSceneView.Repaint(); } linkableOutputSlotIndex = i; } EditorGUILayout.EndHorizontal(); if (i < lastIndex) { sp.Next(false); // advance without drilling into children } } } serializedObject.ApplyModifiedProperties(); } EditorGUILayout.Separator(); DrawDefaultInspector(); } }
private void OnEnable() { node = (BaseCutsceneNode)target; }