public void OnPointerUp(PointerEventData eventData) { // When the pointer is released, get the Ultimate Radial Menu's current button index. int index = UltimateRadialMenu.GetUltimateRadialMenu("ItemWheelExample").CurrentButtonIndex; // If the index is greater than zero ( meaning that the input was on the radial menu ), and this button information does not currently exist on the menu... if (index >= 0 && !usedIndex.Contains(index) && !newRadialButtonInfo.ExistsOnRadialMenu()) { // Update the radial button at the targeted index with this information, and register the ButtonCallback function as the ButtonCallback parameter. UltimateRadialMenu.RegisterToRadialMenu("ItemWheelExample", UseItem, newRadialButtonInfo, index); // Add this index to the used index list so that other buttons know that this button is taken. usedIndex.Add(index); } // Increase this items count. itemCount++; // If this button does exist on the radial menu, then update the text of the button. if (newRadialButtonInfo.ExistsOnRadialMenu()) { newRadialButtonInfo.UpdateText(itemCount.ToString()); } // Update this transform back to the original position. myTransform.localPosition = originalPosition; }
private void Update() { // If the left mouse button is down on the frame... if (Input.GetMouseButtonDown(0)) { // Cast a ray so that we can check if the mouse position is over an object. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // If the raycast hit something, then store the hit transform. if (Physics.Raycast(ray, out hit)) { onMouseDownTransform = hit.transform; } // Else, if the radial menu is active and the mouse is not over a button of the radial menu, then disable the menu. else if (UltimateRadialMenu.GetUltimateRadialMenu("ObjectExample").RadialMenuActive&& UltimateRadialMenu.GetUltimateRadialMenu("ObjectExample").CurrentButtonIndex < 0) { UltimateRadialMenu.GetUltimateRadialMenu("ObjectExample").DisableRadialMenu(); } } // If the left mouse button came up on this frame... if (Input.GetMouseButtonUp(0)) { // Cast a ray so that we can check if the mouse position is over an object. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // If the raycast hit something... if (Physics.Raycast(ray, out hit)) { // If the hit transform is the same as the transform when the mouse button was pressed... if (hit.transform == onMouseDownTransform) { // Store the selected renderer as the hit transform. selectedRenderer = hit.transform.GetComponent <Renderer>(); // Configure the screen position of the hit transform. Vector3 screenPosition = Camera.main.WorldToScreenPoint(hit.transform.position); // Call SetPosition() on the radial menu to move it to the transform's position. UltimateRadialMenu.GetUltimateRadialMenu("ObjectExample").SetPosition(screenPosition); // If the radial menu is currently disabled, then enable the menu. if (!UltimateRadialMenu.GetUltimateRadialMenu("ObjectExample").RadialMenuActive) { UltimateRadialMenu.GetUltimateRadialMenu("ObjectExample").EnableRadialMenu(); } } } } }
void Start() { UltimateRadialMenu.EnableRadialMenu("ItemWheelExample"); UltimateRadialMenu.GetUltimateRadialMenu("ItemWheelExample").OnRadialMenuEnabled += OnRadialMenuEnabled; UltimateRadialMenu.GetUltimateRadialMenu("ItemWheelExample").OnRadialMenuDisabled += OnRadialMenuDisabled; }