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 Start() { for (int i = 0; i < cubeColors.Length; i++) { cubeColors[i].buttonInfo.id = i; UltimateRadialMenu.RegisterToRadialMenu("ObjectExample", UpdateCubeColor, cubeColors[i].buttonInfo); } }
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() { // If the game is not running, then return. if (!Application.isPlaying) { return; } // Subscribe to the needed events of the radial menu. radialMenu.OnUpdatePositioning += OnUpdatePositioning; radialMenu.OnRadialButtonEnter += OnRadialButtonEnter; radialMenu.OnRadialMenuLostFocus += OnRadialMenuLostFocus; radialMenu.OnRadialMenuDisabled += OnRadialMenuDisabled; radialMenu.OnRadialMenuButtonCountModified += OnRadialMenuButtonCountModified; // Attempt to assign it. radialMenu = GetComponentInParent <UltimateRadialMenu>(); // If it is still null, return to avoid errors. if (radialMenu == null) { Debug.LogError("Ultimate Radial Menu Pointer\nThis component is not placed within an Ultimate Radial Menu. Disabling this component to avoid errors."); enabled = false; return; } // Attempt to find the pointer rect transform. pointerTransform = GetComponent <RectTransform>(); // If the pointer is still null, then warn the user and disable this component to avoid errors. if (pointerTransform == null) { Debug.LogError("Ultimate Radial Menu Pointer\nThis gameObject does not have an RectTransform component. Disabling this component to avoid errors."); enabled = false; return; } pointerImage = GetComponent <Image>(); // If the image is still null, then warn the user and disable this component to avoid errors. if (pointerImage == null) { Debug.LogError("Ultimate Radial Menu Pointer\nThis gameObject does not have an Image component. Disabling this component to avoid errors."); enabled = false; return; } // If the user wants to change colors, then apply the normal color here. if (colorChange && pointerImage != null) { pointerImage.color = normalColor; } }
/// <summary> /// [INTERNAL] Called by each Ultimate Radial Menu. /// </summary> public void AddRadialMenuToList(UltimateRadialMenu radialMenu) { // Add this radial menu to the list for calculations. UltimateRadialMenuInformations.Add(new UltimateRadialMenuInfomation() { radialMenu = radialMenu }); // If the user wants to use touch input, then store this radial menu. if (touchInput) { TouchHoldInformations.Add(new TouchHoldInformation() { radialMenu = radialMenu }); radialMenu.OnRadialMenuDisabled += TouchHoldInformations[TouchHoldInformations.Count - 1].ResetMenuPosition; } }
void Awake() { // If the game is not running, then return. if (!Application.isPlaying) { return; } // If the radial menu is null... if (radialMenu == null) { // Attempt to find it in the parent gameobject. radialMenu = GetComponentInParent <UltimateRadialMenu>(); // If the menu is still null, then send an error to the console and disable this component. if (radialMenu == null) { Debug.LogError("Ultimate Radial Menu Pointer\nThere is not a Ultimate Radial Menu assigned to this pointer. This component was not able to find a Ultimate Radial Menu in any parent objects either. Disabling this component to avoid errors."); enabled = false; } } }
void Start() { UltimateRadialMenu.EnableRadialMenu("ItemWheelExample"); UltimateRadialMenu.GetUltimateRadialMenu("ItemWheelExample").OnRadialMenuEnabled += OnRadialMenuEnabled; UltimateRadialMenu.GetUltimateRadialMenu("ItemWheelExample").OnRadialMenuDisabled += OnRadialMenuDisabled; }
// https://www.youtube.com/watch?v=KSE3MMRRWiM // Start is called before the first frame update void Start() { UltimateRadialMenu.RegisterToRadialMenu("MenuTree", OrderMenu, exampleButton); buttonInfo.UpdateText("Order Food"); RadialContent orderFoodRadial = new RadialContent(new List <string> { "Order Food" }, 1); RadialContent pizzaRadial = new RadialContent(new List <string> { "Pizza" }, 2); RadialContent pizzaSizeRadial = new RadialContent(new List <string> { "Small", "Medium", "Large", "X-Large", "Party Size" }, 3); RadialContent pizzaSauceRadial = new RadialContent(new List <string> { "Toppings", "Pizza Sauce", "Cheese" }, 4); RadialContent sauceToppings = new RadialContent(new List <string> { "Pizza Sauce(Light/Normal/Extra)", "BBQ Sauce", "Alfredo Sauce", "Hearty Marinara Sauce", "Ranch Dressing", "Garlic Parmesan Sauce" }, 5); RadialContent toppingsRadial = new RadialContent(new List <string> { "Pepperoni", "Brooklyn Pepperoni", "Sausage", "Beef Crumble", "Ham", "Bacon", "More Toppings" }, 6); RadialContent toppingsRadialMore = new RadialContent(new List <string> { "Chicken", "Anchovy", "Cheddar", "Feta", "Parmesan Asiago", "Provolone" }, 7); RadialContent paymentRadial = new RadialContent(new List <string> { "Deliver Now", "Toggle Purchase Method", "Place Order" }, 8); // Toggle Purchase method -> (Mastercard / debit card / Credit Card) // Place Order -> Order Confirmation // Delivery Now -> (Use Geolocation to pick closes pizza store) // Creating a strongly typed list of objects that can be accessed by index... Providing us the ability to use search, sort, and manipulate list... radialList.Add(new RadialList() { RadialListName = "orderFoodRadial", RadialListId = 0001 }); radialList.Add(new RadialList() { RadialListName = "pizzaRadial", RadialListId = 0002 }); radialList.Add(new RadialList() { RadialListName = "pizzaSizeRadial", RadialListId = 0003 }); radialList.Add(new RadialList() { RadialListName = "pizzaSauceRadial", RadialListId = 0004 }); radialList.Add(new RadialList() { RadialListName = "sauceToppings", RadialListId = 0005 }); radialList.Add(new RadialList() { RadialListName = "toppingsRadial", RadialListId = 0006 }); radialList.Add(new RadialList() { RadialListName = "toppingsRadialMore", RadialListId = 0007 }); radialList.Add(new RadialList() { RadialListName = "paymentRadial", RadialListId = 0008 }); // Write out all the parts in the RadialList. // print("This is a line we are writting"); /* * foreach (RadialList aList in radialList) * { * print(aList); * } * */ }