/// <summary> /// The method is invoked when a button on the right controller is pressed. /// </summary> /// <param name="buttonName">The name of the button</param> /// <param name="selected">The selected object, if there is</param> private void GetRightControllerInput(Controller.ButtonName buttonName, GameObject selected) { if (buttonName == Controller.ButtonName.Button3 && !rightController.IsButtonHeldDown()) { // We add a new node if (_status == Button8Status.AddNode) { _status = Button8Status.None; // We add the node graph.GetComponent <Graph>().AddNode(rightController.GetPivot(), node); // we reset Destroy(_spawnedElement); //rightController.DestroyEmptyPivot(); } else if (_status == Button8Status.AddEdge) { if (_sourceSelected) { edgeTrg = selected.GetComponent <Node>(); graph.GetComponent <Graph>().AddEdge(edgeSrc, edgeTrg, edge); _status = Button8Status.None; _sourceSelected = false; rightController.EmptyInputData(); edgeTrg.IncreaseNodeEmissionIntensity(); GetComponent <InputFeedbackSystem>().LightEnvironment(); } else { // If it is not a node we do not proceed if (!selected.gameObject.CompareTag("node")) { return; } edgeSrc = selected.GetComponent <Node>(); _sourceSelected = true; rightController.DeleteSelectedObject(); edgeSrc.IncreaseNodeEmissionIntensity(); } } else if (_status == Button8Status.None) { // in this case we have no object selected if (!selected) { return; } if (selected.CompareTag("node")) { if (_nodeMenuIsOpen) { nodeMenu.Close(); } OpenNodeMenu(selected); } else if (selected.CompareTag("edge")) { OpenEdgeMenu(selected); } } } else if (buttonName == Controller.ButtonName.Button3 && rightController.IsButtonHeldDown()) { // in this case we have no object selected if (!selected) { return; } if (selected.CompareTag("menu") || selected.CompareTag("edge")) { return; } // We drag the node var pivotPosition = rightController.GetPivot(); if (pivotPosition.gameObject.name == "void") { return; } selected.transform.position = Vector3.Lerp( selected.transform.position, // original pos pivotPosition.position, // new pos Time.deltaTime * 10.0f); // speed } else if (buttonName == Controller.ButtonName.Button8) { ChangeButton8Status(); SpawnElementOnJoystick(rightController.GetPivot()); if (_status == Button8Status.None) { rightController.DestroyEmptyPivot(); } } }