Game.UI.Editor.Item
Assembly:
Namespace: Game.UI.Editor
Type: class
Base: Implements IItemPicker.Item, System.IComparable
Summary:
Represents an entry/item used by the editor item picker UI. Stores the item's name, runtime type, full name string, and an optional parent directory. Provides a computed relativePath that combines parentDir and name when parentDir is present. Implements IComparable
Fields
- (none declared in source)
There are no explicit private fields in the source. The auto-implemented properties will have compiler-generated backing fields.
Properties
-
public string parentDir { get; set; }
Nullable. Optional parent directory used to compute relativePath. Annotated with [CanBeNull] in the source. -
public string name { get; set; }
The short name of the item (used for display and comparisons). -
public Type type { get; set; }
The System.Type associated with this item (e.g., the asset or editor type). -
public string fullName { get; set; }
A full name string for the item (could be a fully qualified name or long display name). -
public string relativePath { get; }
Nullable. Read-only computed property. If parentDir is non-null, returns Path.Combine(parentDir, name); otherwise returns name. Annotated [CanBeNull] in the source.
Constructors
public Item()
No explicit constructors are declared in the source; the compiler will provide the default parameterless constructor.
Methods
public int CompareTo(Item other)
Implements comparison for sorting. Behavior:- First compares a "favorite" value (referenced in source as
base.favorite) to prefer favorite items. The code uses-base.favorite.CompareTo(other.favorite)so favorites are ordered before non-favorites (descending). - If the favorite values are equal, it falls back to
string.CompareOrdinal(name, other.name), performing an ordinal string comparison of the name values. Notes: - The source references
base.favorite. In typical C# this implies a favorite member is declared on a base class; however the class signature in the provided source shows it implementing interfaces only. In the real codebase,favoritelikely comes from a base class or the decompiled code usesbase.to reference an inherited member. When using or modifying this method, ensure the favorite member is available in the actual inheritance hierarchy.
Usage Example
// create items
var a = new Game.UI.Editor.Item { parentDir = "Props", name = "Bench", type = typeof(object), fullName = "Props.Bench" };
var b = new Game.UI.Editor.Item { parentDir = null, name = "Tree", type = typeof(object), fullName = "Nature.Tree" };
// compute relative paths
Console.WriteLine(a.relativePath); // "Props\Bench" on Windows
Console.WriteLine(b.relativePath); // "Tree"
// sorting example (assuming favorite member exists and is set appropriately)
var list = new List<Game.UI.Editor.Item> { a, b };
list.Sort(); // uses CompareTo to order by favorite then name