Exemplo n.º 1
0
        private void OnSelectionChanged()
        {
            var newDialogue = Selection.activeObject as Dialogue.Dialogue;

            if (newDialogue == null)
            {
                return;
            }

            if (_toolbar != null)
            {
                rootVisualElement.Remove(_toolbar);
            }

            _selectedDialogue = newDialogue;
            Repaint();

            _toolbar = new Toolbar();
            var button = new Button(() => _selectedDialogue.CreateNode(null))
            {
                text = "Create Node",
            };

            _toolbar.Add(button);
            rootVisualElement.Add(_toolbar);
        }
Exemplo n.º 2
0
        private void OnGUI()
        {
            if (_selectedDialogue == null)
            {
                EditorGUILayout.LabelField("No Dialogue Selected.");
            }
            else
            {
                ProcessEvents();

                _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

                var canvas        = GUILayoutUtility.GetRect(CanvasSize, CanvasSize);
                var backgroundTex = Resources.Load("background") as Texture2D;
                var texCoords     = new Rect(0, 0, CanvasSize / BackgroundSize, CanvasSize / BackgroundSize);
                GUI.DrawTextureWithTexCoords(canvas, backgroundTex, texCoords);

                foreach (var node in _selectedDialogue.GetAllNodes())
                {
                    DrawConnections(node);
                }

                foreach (var node in _selectedDialogue.GetAllNodes())
                {
                    DrawNode(node);
                }

                EditorGUILayout.EndScrollView();

                if (creatingNode != null)
                {
                    _selectedDialogue.CreateNode(creatingNode);
                    creatingNode = null;
                }

                if (_deletingNode != null)
                {
                    _selectedDialogue.DeleteNode(_deletingNode);
                    _deletingNode = null;
                }
            }
        }