public void UpdateSelectedUISpellNode(UISpellNode uisn) { if (selectionMode == SelectionMode.None) { // drag = true; selectionMode = SelectionMode.Drag; dragableObj = uisn.gameObject; offset = (Vector2)(uisn.transform.position - Input.mousePosition); selectedSpace = SelectionSpace.UI; UpdateSelectedSpellNode(uisn.linkedSpellNode); mostRecentlySelected = ModifyableUITypes.Node; } else if (selectionMode == SelectionMode.DataLink || selectionMode == SelectionMode.TransitionLink) { Debug.Log("Creating Link with source " + selectedUISN.gameObject.name + " and destination " + uisn.gameObject.name); CreateLink(selectedUISN, uisn); mostRecentlySelected = ModifyableUITypes.Link; } }
void Update() { if (Input.GetMouseButtonDown(0)) { // if left click is pressed... if (selectionMode == SelectionMode.None) { // Checking if a spell node in the game world is clicked. This is // to allow the user to drag the spell node around in user space Vector3 mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); Collider2D obj = Physics2D.OverlapPoint((Vector2)mousePoint); if (obj != null) { SpellNode sn = obj.GetComponent <SpellNode>(); if (sn != null) { // drag = true; selectionMode = SelectionMode.Drag; dragableObj = sn.gameObject; offset = (Vector2)(sn.transform.position - mousePoint); selectedSpace = SelectionSpace.World; UpdateSelectedSpellNode(sn); } } } else if (selectionMode == SelectionMode.TransitionLink) { } } if (selectedSpellNode == null && selectedLink == null) { UpdateDetailsPanel(0); } // if( Input.GetMouseButtonDown(2) ) // { // if( selectedMagicCircle != null ) // { // Vector3 mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); // Collider2D obj = Physics2D.OverlapPoint( (Vector2) mousePoint ); // if( obj != null ) // { // MagicCircle mc = obj.GetComponent<MagicCircle>(); // if( mc != null && selectedMagicCircle != mc) // { // linkableSourceMagicCircle = mc; // print( linkablePropertiesSink.captionText.text ); // string[] linkableMethods = LinkableFinder.FindPropertiesToLinkTo( linkablePropertiesSink.captionText.text, selectedMagicCircle, linkableSourceMagicCircle ); // // linkablePropertiesSource.options.Clear(); // for(int i = 0; i < linkableMethods.Length; i++ ) // { // linkablePropertiesSource.options.Add( new Dropdown.OptionData( linkableMethods[i] ) ); // } // linkablePropertiesSource.RefreshShownValue(); // } // } // } // } // Unselect something when you right click if (Input.GetMouseButtonDown(1) && (selectedLink == null || (selectedLink != null && !selectedLink.isClicked))) { DeselectAll(); } // Stop dragging when you release the mouse if (Input.GetMouseButtonUp(0)) { if (selectionMode == SelectionMode.Drag) { // drag = false; selectionMode = SelectionMode.None; } } // Drag selected item if (selectionMode == SelectionMode.Drag) { Vector3 mousePoint; if (selectedSpace == SelectionSpace.World) { mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); } else { mousePoint = Input.mousePosition; } dragableObj.transform.position = new Vector3(mousePoint.x, mousePoint.y, dragableObj.transform.position.z) + (Vector3)offset; } else if (selectionMode == SelectionMode.TransitionLink || selectionMode == SelectionMode.DataLink) { selectedLink.SetPoint(selectedLink.points.Count - 1, Input.mousePosition); } }