Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
 public void AddChild(DialogueNode parent, DialogueNode child)
 {
     parent.AddChild(child.name);
     OnValidate();
 }