private void CreateSetNode() { 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); string dataid = SessionManager.Instance.selectedSceneObject.data.id; Node node = rg.graph.AddNode(typeof(SetNTVariableNode)); node.position = nodePosition; node.name = "SET - (" + SessionManager.Instance.selectedSceneObject.name + ")"; if (propertyType == PropertyType.SceneReference) { Debug.LogWarning("Not valid option"); //FIXME: Avoid setting scene references as user can mess up things.. //((SetNTVariableNode) node).SetVariableKey(SessionManager.Instance.selectedSceneObject.data.id, typeof(string), path, typeof(SceneGameObject) ); } else { ((SetNTVariableNode)node).SetVariableKey(dataid, typeof(string), path, data.GetType()); } rg.Refresh(); }
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; }