private DialogueNode MakeNode(DialogueNode parent) { var newNode = CreateInstance <DialogueNode>(); newNode.name = Guid.NewGuid().ToString(); if (parent != null) { parent.AddChild(newNode.name); newNode.SetPlayerSpeaking(!parent.IsPlayerSpeaking()); newNode.SetPosition(parent.GetRect().position + newNodeOffset); } return(newNode); }
public void CreateNode(DialogueNode parent) { DialogueNode newNode = CreateInstance <DialogueNode>(); newNode.name = Guid.NewGuid().ToString(); Undo.RegisterCreatedObjectUndo(newNode, "Created Dialogue Node"); if (parent != null) { parent.AddChild(newNode.name); newNode.SetIsPlayerSpeaking(!parent.IsPlayerSpeaking()); newNode.SetPosition(parent.GetRect().position + newNodeOffset); } if (AssetDatabase.GetAssetPath(this) != "") { Undo.RecordObject(this, "Added Dialogue Node"); } nodes.Add(newNode); OnValidate(); }
public void CreateNode(DialogueNode parentNode) { DialogueNode node = CreateInstance <DialogueNode>(); node.name = Guid.NewGuid().ToString(); Undo.RegisterCreatedObjectUndo(node, "Dialogue Object Created"); node.SetIsPlayer(!parentNode.IsPlayerSpeech); Rect tempRect = new Rect(node.PositionRect); tempRect.center = new Vector2(parentNode.PositionRect.center.x + 1.5f * parentNode.PositionRect.width, parentNode.PositionRect.center.y); node.PositionRect = tempRect; parentNode.AddChild(node.name); Undo.RecordObject(this, "Dialogue Node Added"); _dialogueNodes.Add(node); if (!_nodeLookup.ContainsKey(node.name)) { _nodeLookup[node.name] = node; } }
public void CreateNewNode(DialogueNode parent) { if (AssetDatabase.GetAssetPath(this) != "") { Undo.RecordObject(this, "Added New Dialogue Node"); } //dont use the new keyword to create a new SO (as we do for a regular class), //we call CreateInstance<T> to create an instance of a scriptable object //DialogueNode node = new DialogueNode(); DialogueNode node = CreateInstance <DialogueNode>(); node.name = System.Guid.NewGuid().ToString(); nodes.Add(node); if (parent != null) { parent.AddChild(node.name); node.SetRectPosition(parent.RectPosition.position + newNodeOffset); if (!parent.IsPlayerSpeaking()) { node.SetIsPlayerSpeaking(true); } } //unity will actually combine both undos into 1 step Undo.RegisterCompleteObjectUndo(node, "Create New Dialogue Node"); //moved to callback OnBeforeSerialize. Otherwise it may try to add a node to a new Dialogue before Dialogue is saved. //AssetDatabase.AddObjectToAsset(node, this); OnValidate(); }
public void AddChild(DialogueNode parent, DialogueNode child) { parent.AddChild(child.name); OnValidate(); }