public static AddComponentMenuItem Group(string groupLabel, [CanBeNull] AddComponentMenuItem setParent, Texture setPreview) { #if DEV_MODE && PI_ASSERTATIONS if (string.Equals(groupLabel, "Unity Engine")) { Debug.LogError("AddComponentMenu Group \"" + groupLabel + "\" being created."); } #endif var group = new AddComponentMenuItem(); group.label = groupLabel; group.parent = setParent; group.children = ArrayPool <AddComponentMenuItem> .ZeroSizeArray; group.preview = setPreview; if (setPreview != null) { group.previewFetched = true; group.fetchedPreviewNotNull = true; } #if DEV_MODE if (group.previewFetched) { Debug.Log("Group \"" + groupLabel + "\" fetched with previewFetched=" + true + ", preview=" + setPreview.name); } #endif return(group); }
private void SetActiveItem(AddComponentMenuItem value) { activeItem = value; UpdateCategoryLabel(); RebuildIntructionsInChildren(); GUI.changed = true; }
/// <summary> Creates a new instance of the drawer or returns a reusable instance from the pool. </summary> /// <param name="item"> Information about the menu item. </param> /// <returns> The drawer instance, ready to be used. </returns> public static AddComponentMenuItemDrawer Create(AddComponentMenuItem item) { AddComponentMenuItemDrawer result; if (!DrawerPool.TryGet(out result)) { result = new AddComponentMenuItemDrawer(); } result.Setup(item); result.LateSetup(); return(result); }
private void SetValues(AddComponentMenuItem set, ref Dictionary <string, Texture> groupsDictionary, ref List <AddComponentMenuItemConfig> itemsList) { if (set.IsGroup) { groupsDictionary[set.FullLabel()] = set.Preview; for (int n = 0, count = set.children.Length; n < count; n++) { SetValues(set.children[n], ref groupsDictionary, ref itemsList); } } else { itemsList.Add(new AddComponentMenuItemConfig(set.FullLabel(), set.type)); } }
public static AddComponentMenuItem Item([NotNull] Type setType, string classLabel, [CanBeNull] AddComponentMenuItem setParent) { #if DEV_MODE && PI_ASSERTATIONS if (setParent != null && string.Equals(setParent.label, "Unity Engine")) { Debug.LogError("AddComponentMenu Item \"" + classLabel + "\" being created under \"Unity Engine\" group. Type should be added under a more descriptive Group in InspectorPreferences.addComponentMenuConfig."); } Debug.Assert(setType != null); #endif var item = new AddComponentMenuItem(); item.parent = setParent; item.label = classLabel; item.type = setType; return(item); }
public static AddComponentMenuItem Group(string groupLabel, AddComponentMenuItem setParent, Texture setPreview = null) { #if DEV_MODE && PI_ASSERTATIONS if (string.Equals(groupLabel, "Unity Engine")) { Debug.LogError("AddComponentMenu Group \"" + groupLabel + "\" being created."); } #endif var group = new AddComponentMenuItem(); group.label = groupLabel; group.parent = setParent; group.children = new AddComponentMenuItem[0]; group.preview = setPreview; group.previewFetched = setPreview != null; return(group); }
private static AddComponentMenuItem GetOrCreateRootItem(string label, Type type) { for (int n = rootGroups.Length - 1; n >= 0; n--) { var test = rootGroups[n]; if (test.type == type) { return(test); } } //create the item if it didn't exist var newItem = AddComponentMenuItem.Item(type, label, null); ArrayExtensions.Add(ref rootGroups, newItem); return(newItem); }
private static AddComponentMenuItem GetOrCreateGroup(ref List <string> groupsLabels, AddComponentMenuItem parent, ref AddComponentMenuItem[] options, Texture icon) { //first try to find an existing group with given group labels string rootGroup = groupsLabels[0]; for (int i = options.Length - 1; i >= 0; i--) { var group = options[i]; if (string.Equals(group.label, rootGroup)) { groupsLabels.RemoveAt(0); if (groupsLabels.Count > 0) { var result = GetOrCreateGroup(ref groupsLabels, group, ref group.children, icon); groupsLabels.Clear(); return(result); } groupsLabels.Clear(); return(group); } } //create the group if it didn't exist var newGroup = AddComponentMenuItem.Group(rootGroup, parent, icon); #if DEV_MODE int countBeforeAdd = options.Length; #endif ArrayExtensions.Add(ref options, newGroup); #if DEV_MODE Debug.Assert(options.Length == countBeforeAdd + 1); #endif if (groupsLabels.Count > 1) { groupsLabels.RemoveAt(0); newGroup = GetOrCreateGroup(ref groupsLabels, parent, ref newGroup.children, icon); } groupsLabels.Clear(); return(newGroup); }
/// <summary> /// Sets up the drawer so that it is ready to be used. /// LateSetup should be called right after this. /// </summary> /// <param name="setItem"> Information about the menu item. </param> private void Setup(AddComponentMenuItem setItem) { item = setItem; label = GUIContentPool.Create(setItem.label); }
private static int Sort(AddComponentMenuItem x, AddComponentMenuItem y) { return(x.label.CompareTo(y.label)); }