Exemple #1
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;
            }
        }