コード例 #1
0
        // Use this for initialization
        void OnEnable()
        {
            var sampleGraphView = new SampleGraphView();

            m_GraphView = sampleGraphView;

            m_GraphView.name           = "theView";
            m_GraphView.persistenceKey = "theView";
            m_GraphView.StretchToParentSize();

            m_NoSelectLabel = new Label("Select a Dialogue Asset in order to view");
            m_NoSelectLabel.style.textAlignment = TextAnchor.MiddleCenter;
            m_NoSelectLabel.StretchToParentSize();
            m_NoSelectLabel.visible = false;

            this.GetRootVisualContainer().Add(m_GraphView);
            this.GetRootVisualContainer().Add(m_NoSelectLabel);
            OnSelectionChanged();

            if (!LoadGraphData())
            {
                DialogueNode node = CreateStartNode();
                node.addOutput();
                m_GraphView.AddElement(node);
            }
            m_GraphView.graphViewChanged    += OnGraphViewChanged;
            m_GraphView.nodeCreationRequest += OnRequestNodeCreation;
            Selection.selectionChanged      += OnSelectionChanged;
        }
コード例 #2
0
    bool ISearchWindowProvider.OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context)
    {
        var type = searchTreeEntry.userData as System.Type;
        var node = Activator.CreateInstance(type) as SampleNode;

        graphView.AddElement(node);
        return(true);
    }
コード例 #3
0
    public virtual bool OnSelectEntry(SearchTreeEntry entry, SearchWindowContext context)
    {
        if (!(entry is SearchTreeGroupEntry))
        {
            Node node = CreateNode("Default", 1, 1);
            m_GraphView.AddElement(node);
            node.SetPosition(new Rect(new Vector2(10, 100), Vector2.zero));

            m_GraphView.AddElement(node);

            Vector2 pointInWindow = context.screenMousePosition - position.position;
            Vector2 pointInGraph  = node.parent.WorldToLocal(pointInWindow);

            node.SetPosition(new Rect(pointInGraph, Vector2.zero)); // it's ok to pass zero here because width/height is dynamic

            node.Select(m_GraphView, false);
            return(true);
        }
        return(false);
    }
コード例 #4
0
        public void ShowScript(SerializableDialogData data)
        {
            m_DialogData = data;

            if (!LoadGraphData())
            {
                DialogueNode node = CreateStartNode();
                node.addOutput();
                m_GraphView.AddElement(node);
            }
        }
コード例 #5
0
    // Use this for initialization
    void OnEnable()
    {
        var sampleGraphView = new SampleGraphView();

        m_GraphView = sampleGraphView;

        m_GraphView.name           = "theView";
        m_GraphView.persistenceKey = "theView";
        m_GraphView.StretchToParentSize();

        this.GetRootVisualContainer().Add(m_GraphView);

        if (!LoadGraphData(k_TestGraphDataPath))
        {
            Node node = CreateRootNode();
            m_GraphView.AddElement(node);
        }

        m_GraphView.graphViewChanged    += OnGraphViewChanged;
        m_GraphView.nodeCreationRequest += OnRequestNodeCreation;
    }