public void CreateNode(DialogueNode parent) { DialogueNode newNode = CreateInstance <DialogueNode>(); newNode.name = Guid.NewGuid().ToString(); if (parent != null) { parent.AddChild(newNode.name); newNode.SetPlayerIsSpeaking(!parent.IsPlayerSpeaking()); newNode.SetPosition(parent.GetRect().position + newNodeOffset); } Undo.RegisterCreatedObjectUndo(newNode, "Created Dialogue Node"); if (AssetDatabase.GetAssetPath(this) != "") { Undo.RecordObject(this, "Added Dialogue Node"); } nodes.Add(newNode); OnValidate(); }