Game.UI.Editor.PrefabItem
Assembly: Assembly-CSharp
Namespace: Game.UI.Editor
Type: public class
Base: IItemPicker.Item, System.IComparable
Summary:
Represents an entry used by the editor item picker for a prefab. Holds a reference to a PrefabBase (nullable) and a list of tags, and provides a comparison implementation so lists of PrefabItem can be sorted — favorites first, then by prefab name using an ordinal string comparison.
Fields
- (No explicit public or private fields declared in source; only auto-properties produce compiler-generated backing fields)
This class relies on auto-implemented properties. Any backing fields are generated by the compiler and are not declared in the source.
Properties
-
public PrefabBase prefab { get; set; }
Nullable reference to the prefab this item represents. Marked with [CanBeNull]. Used for name-based comparisons and for identifying the prefab in the UI or logic that consumes PrefabItem instances. -
public List<string> tags { get; set; } = new List<string>();
A list of string tags associated with the prefab. Initialized to an empty Listby default. Useful for filtering, categorization, or searching in the item picker.
Constructors
public PrefabItem()
No explicit constructor is defined in the source; the compiler provides a parameterless default constructor. The default constructor initializes the tags property to an empty list (per the property initializer) and leaves prefab null unless set.
Methods
public int CompareTo(PrefabItem other)
Compares this PrefabItem with another for ordering purposes. Implementation details:- If the inherited favorite status (base.favorite) differs between the two items, favorites are ranked before non-favorites. The code uses -base.favorite.CompareTo(other.favorite) to reverse the natural order of the favorite comparison so that "true" favorites sort ahead of "false".
- If favorite status is equal, the comparison falls back to an ordinal string comparison of the prefab names: string.CompareOrdinal(prefab?.name, other.prefab?.name). The null-conditional operator is used, so null prefab or null names are handled by the string comparison semantics (null is treated as less than a non-null string).
- Returns an int compatible with IComparable: negative if this item precedes other, zero if equal, positive if this item follows other.
Usage Example
// Create and populate items
var itemA = new PrefabItem { prefab = somePrefabA };
var itemB = new PrefabItem { prefab = somePrefabB };
// Mark favorites via the inherited member (example; actual member name/type depends on IItemPicker.Item)
itemA.favorite = true; // assuming base.favorite is accessible here
// Put items in a list and sort
var list = new List<PrefabItem> { itemA, itemB };
list.Sort(); // uses CompareTo: favorites first, then by prefab.name (ordinal)
// Typical use: item picker UI can bind to the sorted list; tags can be used for filtering
itemA.tags.Add("residential");
itemB.tags.Add("landmark");