public void OnMakePersistent() { DebugMenuItem selectedItem = m_DebugMenus[m_ActiveMenuIndex].GetSelectedDebugMenuItem(); if (selectedItem != null && selectedItem.readOnly) { if (m_PersistentDebugMenu.HasItem(selectedItem)) { m_PersistentDebugMenu.RemoveDebugItem(selectedItem); } else { m_PersistentDebugMenu.AddDebugItem(selectedItem); } } if (m_PersistentDebugMenu.itemCount == 0) { m_PersistentDebugMenu.SetSelected(false); m_DebugMenuUI.EnablePersistentView(false); // Temp, should just need the above. Wait for background UI to be moved to menu itself } else { m_PersistentDebugMenu.SetSelected(true); m_DebugMenuUI.EnablePersistentView(true); } }
public virtual DebugMenuItemUI BuildGUI(GameObject parent, DebugMenuItem menuItem) { DebugMenuItemUI newItemUI = null; if (menuItem.GetItemType() == typeof(bool)) { newItemUI = new DebugMenuBoolItemUI(parent, menuItem, m_Label.text); } else if (menuItem.GetItemType() == typeof(int)) { newItemUI = new DebugMenuIntItemUI(parent, menuItem, m_Label.text); } else if (menuItem.GetItemType() == typeof(uint)) { newItemUI = new DebugMenuUIntItemUI(parent, menuItem, m_Label.text); } else if (menuItem.GetItemType() == typeof(float)) { newItemUI = new DebugMenuFloatItemUI(parent, menuItem, m_Label.text); } else if (menuItem.GetItemType() == typeof(Color)) { newItemUI = new DebugMenuColorItemUI(parent, menuItem, m_Label.text); } else if (m_MenuItem.GetItemType().BaseType == typeof(System.Enum)) { newItemUI = new DebugMenuEnumItemUI(parent, menuItem, m_Label.text, m_EnumStrings.ToArray(), m_EnumValues.ToArray()); } return(newItemUI); }
public DebugMenuColorItemUI(GameObject parent, DebugMenuItem menuItem, string name) : base(menuItem) { m_MenuItem = menuItem; m_Root = DebugMenuUI.CreateHorizontalLayoutGroup(name, true, true, false, false, parent); m_Name = DebugMenuUI.CreateTextElement(m_MenuItem.name, name, 10, TextAnchor.MiddleLeft, m_Root); var layoutElemName = m_Name.AddComponent <UI.LayoutElement>(); layoutElemName.minWidth = DebugMenuUI.kDebugItemNameWidth; // Force layout because we need the right height for the color rect element afterward. UI.LayoutRebuilder.ForceRebuildLayoutImmediate(m_Root.GetComponent <RectTransform>()); RectTransform nameRect = m_Name.GetComponent <RectTransform>(); m_ColorRect = new GameObject(); m_ColorRect.transform.SetParent(m_Root.transform, false); m_ColorRect.AddComponent <UI.Image>(); UI.LayoutElement layoutElem = m_ColorRect.AddComponent <UI.LayoutElement>(); // We need to set min width/height because without an image, the size would be zero. layoutElem.minHeight = nameRect.rect.height; layoutElem.minWidth = 40.0f; Update(); }
public DebugMenuEnumItemUI(GameObject parent, DebugMenuItem menuItem, string name, GUIContent[] valueNames, int[] values) : base(parent, menuItem, name) { m_Values = values; m_ValueNames = valueNames; m_CurrentValueIndex = FindIndexForValue((int)m_MenuItem.GetValue()); Update(); }
protected DebugMenuSimpleItemUI(GameObject parent, DebugMenuItem menuItem, string name) : base(menuItem) { m_Root = DebugMenuUI.CreateHorizontalLayoutGroup("", true, true, false, false, parent); m_Name = DebugMenuUI.CreateTextElement(m_MenuItem.name, name, 10, TextAnchor.MiddleLeft, m_Root); var layoutElem = m_Name.AddComponent <UI.LayoutElement>(); layoutElem.minWidth = DebugMenuUI.kDebugItemNameWidth; m_Value = DebugMenuUI.CreateTextElement(string.Format("{0} value", name), "", 10, TextAnchor.MiddleLeft, m_Root); }
public void AddDebugMenuItem <ItemType>(string name, Func <object> getter, Action <object> setter, bool dynamicDisplay = false, DebugItemDrawer drawer = null) { if (drawer == null) { drawer = new DebugItemDrawer(); } DebugMenuItem newItem = new DebugMenuItem(name, typeof(ItemType), getter, setter, dynamicDisplay, drawer); drawer.SetDebugItem(newItem); m_Items.Add(newItem); }
public bool HasItem(DebugMenuItem debugItem) { foreach (var item in m_Items) { if (debugItem == item) { return(true); } } return(false); }
public void SetDebugItem(DebugMenuItem item) { m_MenuItem = item; m_Label = new GUIContent(m_MenuItem.name); Type itemType = m_MenuItem.GetItemType(); if (itemType.BaseType == typeof(System.Enum)) { Array arr = Enum.GetValues(itemType); m_EnumStrings = new List <GUIContent>(arr.Length); m_EnumValues = new List <int>(arr.Length); foreach (var value in arr) { m_EnumStrings.Add(new GUIContent(value.ToString())); m_EnumValues.Add((int)value); } } }
public override DebugMenuItemUI BuildGUI(GameObject parent, DebugMenuItem menuItem) { return(new DebugMenuEnumItemUI(parent, menuItem, m_Label.text, m_EnumStrings, m_EnumValues)); }
public void AddDebugItem(DebugMenuItem debugItem) { m_Items.Add(debugItem); RebuildGUI(); }
public void RemoveDebugItem(DebugMenuItem debugItem) { m_Items.Remove(debugItem); RebuildGUI(); }
public DebugMenuBoolItemUI(GameObject parent, DebugMenuItem menuItem, string name) : base(parent, menuItem, name) { Update(); }
public DebugMenuUIntItemUI(GameObject parent, DebugMenuItem menuItem, string name) : base(parent, menuItem, name) { UpdateText((int)(uint)m_MenuItem.GetValue()); }
public DebugMenuIntegerItemUI(GameObject parent, DebugMenuItem menuItem, string name) : base(parent, menuItem, name) { }
protected DebugMenuItemUI(DebugMenuItem menuItem) { m_MenuItem = menuItem; }