private void OnHoldEvents_functionMenu(MenuController.MenuElementInfo sender) { //finds out if it is an existing, or a new Item var ExistingUIElement = currentMenuInformationState.myUIContainerData.Find(x => x.adress == sender.ID); if (ExistingUIElement != null) { //we want to display the adress already ticked in the menu generateMenu_Adress(ExistingUIElement.function_UIContainer, ExistingUIElement.adress); } }
//starts the next menu step private void OnSelectEvents_resourcesMenu(MenuController.MenuElementInfo sender) { if (sender.isSelected) { // we have nothing to do on deselection events currentMenuInformationState.DeviceType3D = sender.ID; //id is current state MenuAdress.resetMenu(); generateMenu_ButtonFunction(); } else { MenuFunction.resetMenu(); MenuAdress.resetMenu(); } }
private void OnSelectEvents_AdressMenu(MenuController.MenuElementInfo sender) { if (!sender.isSelected) // we have nothing to do on deselection events { return; } bool newItem = false; //we insert part of one sub-tupel (address - Function) //find out if it is a new item var currentlySelected = MenuAdress.getSelectedItem().ID; //currently selected in adress menu AppData.uniqueIDDevice.UIContainerData UIContainerData = null; if (currentlySelected != null) { //is there a container data to the currently selected UIContainerData = currentMenuInformationState.myUIContainerData.Find(x => x.adress == currentlySelected); } if (UIContainerData == null) //if there is no container data { // new item needs to be generated UIContainerData = new AppData.uniqueIDDevice.UIContainerData(); newItem = true; } //new chosen adress UIContainerData.adress = sender.ID; if (newItem) { //get the ui Function, that has not been assingned --> uifunction UIContainerData.function_UIContainer = MenuFunction.getSelectedItems().Find(x => UIContainerBar.Instance.getUIElementPrefab(x.ID) != null).ID; //add only if ne item currentMenuInformationState.myUIContainerData.Add(UIContainerData); } //back to the function menu StartCoroutine(restartFunctionMenu()); }
private void generateMenu_Ressources() { MenuResources.resetMenu(); UnityEngine.Object[] resources = Resources.LoadAll(AppDataManager.Instance.resourcePath); foreach (UnityEngine.Object o in resources) { GameObject toAdd = (GameObject)o; TextMesh text = Instantiate(Text_Prefab.gameObject).GetComponent <TextMesh>(); text.text = toAdd.name; // alternative text try //if something goes wrong during one element { //generates the menu element, we listen to select events MenuResources.addMenuElement( toAdd, toAdd.name, text.gameObject, OnSelectEvents_resourcesMenu); } catch { Debug.Log("Element " + toAdd.name + " could not be generated"); } //Tidy up Destroy(text.gameObject); //they made a copy by now } if (!string.IsNullOrEmpty(currentMenuInformationState.baseAdress))//we start with data { MenuController.MenuElementInfo mei = MenuResources.getElementByID(currentMenuInformationState.DeviceType3D); //MenuResources.catchNextDeselectionEvent = true; mei.interactiveToggle.SetSelection(true); //proceed to next function generateMenu_ButtonFunction(); } MenuResources.updateCollection(true); }
private void OnSelectEvents_functionMenu(MenuController.MenuElementInfo sender) { //finds out if it is an existing, or a new Item var ExistingUIElement = currentMenuInformationState.myUIContainerData.Find(x => x.adress == sender.ID); var FreshUIElement = UIContainerBar.Instance.getUIElementPrefab(sender.ID); if (sender.isSelected) //on selection, we procede to the next menu { //we have to differentiate between new menu items, and already existing menu items //so we have to check if the ID of a menu item is a function or a adress if (FreshUIElement != null)//fresh element is a new type { //if it is a fresh unset item //we want to display all adresses, that this element can handle generateMenu_Adress(sender.ID); } else { Debug.LogError("should not happen " + sender.ID); } } else//on deselection, we to remove the item if it is an existin item { if (ExistingUIElement != null) { MenuFunction.removeElement(ExistingUIElement.adress); currentMenuInformationState.myUIContainerData.RemoveAll(x => x.adress == ExistingUIElement.adress); //removes the element } else if (FreshUIElement != null) //fresh element is a new type { //if it is a fresh unset item MenuAdress.resetMenu(); } } }