Example #1
0
    private void CreateGetNode()
    {
        if (!rg)
        {
            return;
        }

        NTScrollRect ntScrollRect = rg.GetComponentInChildren <NTScrollRect>();

        if (ntScrollRect == null)
        {
            return;
        }

        Vector2 nodePosition = Vector2.zero;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(
            (RectTransform)ntScrollRect.content.transform,
            Input.mousePosition, GetComponentInParent <Canvas>().worldCamera, out nodePosition
            );

        nodePosition = new Vector2(nodePosition.x - 80, -nodePosition.y);

        Node node = rg.graph.AddNode(typeof(GetNTVariableNode));

        node.position = nodePosition;
        node.name     = "GET - (" + SessionManager.Instance.selectedSceneObject.name + ")";

        if (propertyType == PropertyType.SceneReference)
        {
            ((GetNTVariableNode)node).SetVariableKey(SessionManager.Instance.selectedSceneObject.data.id, typeof(string), path, typeof(SceneGameObject));
        }
        else
        {
            ((GetNTVariableNode)node).SetVariableKey(SessionManager.Instance.selectedSceneObject.data.id, typeof(string), path, data.GetType());
        }

        rg.Refresh();
    }
Example #2
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (m_DraggingIcon != null)
        {
            Destroy(m_DraggingIcon);
        }

        if (!eventData.pointerCurrentRaycast.gameObject)
        {
            return;
        }

        rg = eventData.pointerCurrentRaycast.gameObject.GetComponentInParent <RuntimeGraph>();

        if (!rg)
        {
            return;
        }

        NTScrollRect ntScrollRect = rg.GetComponentInChildren <NTScrollRect>();

        if (ntScrollRect == null)
        {
            return;
        }

        nodePosition = Vector2.zero;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(
            (RectTransform)ntScrollRect.content.transform,
            Input.mousePosition, GetComponentInParent <Canvas>().worldCamera, out nodePosition
            );

        nodePosition = new Vector2(nodePosition.x - 80, -nodePosition.y);

        OnDragEnd(eventData);

        return;
    }