Tri Inspector Documentation
repository·main·Indexed 23 days ago
https://github.com/codewriter-packages/tri-inspectorA Unity package (version 1.15.1) providing advanced inspector attributes to enhance the Unity Editor's UI and developer workflow. It includes tools for property visibility (ShowInInspector, ReadOnly), validation (Required, ValidateInput), layout organization (Group, TableList), and custom controls (Slider, Button, EnumToggleButtons). Supports Unity 2020.3 and above, and offers compatibility mode with Odin Inspector via the [DrawWithTriInspector] attribute.
What's inside Tri Inspector
- Tri Inspector is a package providing advanced inspector attributes for Unity. It is designed to enhance the Unity Editor's inspector interface through various attributes, validation, decorators, and styling tools. It supports Unity 2020.3 and above.
Integrate Tri Inspector with Odin Validator
mainTri Inspector is integrated with the Odin Validator. All validation results generated by Tri Inspector attributes will automatically appear in the Odin Validator window.Use Tri Inspector with Odin Inspector
mainTri Inspector can operate in compatibility mode with Odin Inspector. In this mode, Odin handles the primary interface, but you can opt-in specific parts to be rendered by Tri Inspector using the
[DrawWithTriInspector]attribute.- Per Class: Mark a class with
[DrawWithTriInspector]to render its interface using Tri Inspector. - Per Assembly: Mark an entire assembly with
[assembly:DrawWithTriInspector]to use Tri Inspector for all types within that assembly.
- Per Class: Mark a class with
Install Tri Inspector via Git URL
mainTri Inspector is distributed as a Unity Package Manager (UPM) git package. To install it, add the following Git URL to your project's package manager:
https://github.com/codewriter-packages/Tri-Inspector.githttps://github.com/codewriter-packages/Tri-Inspector.gitHandle Localization package dependency
mainTri Inspector automatically installs the Unity Localization package as a dependency.
If you do not want to use the full localization package, you can install a stub package instead to satisfy the dependency without the overhead:
https://github.com/codewriter-packages/Unity-Localization-Stub-for-Tri-Inspector.gitAccess Tri Inspector Samples
mainTri Inspector includes built-in samples to demonstrate its capabilities. You can find these samples in the Unity Editor via the following menu path:
Tools/Tri Inspector/SamplesSelect Material properties with MaterialProperty
mainThe
[MaterialProperty]attribute automatically displays valid shader properties from a targetMaterial. Supports types likeColor,Float,Vector, andTextureviaShaderPropertyType.[MaterialProperty(nameof(material))] public string propertyName; [MaterialProperty(nameof(material), ShaderPropertyType.Color)] public int propertyHash; public Material material;Convert enums to toggle buttons with EnumToggleButtons
mainUse
[EnumToggleButtons]to display enum values as a row of toggle buttons instead of a standard dropdown. This works for both standard enums and[Flags]enums.[EnumToggleButtons] public SomeEnum someEnum; [EnumToggleButtons] public SomeFlags someFlags; public enum SomeEnum { One, Two, Three } [Flags] public enum SomeFlags { A = 1 << 0, B = 1 << 1, C = 1 << 2, AB = A | B, BC = B | C, }Enforce required fields with Required
mainThe
[Required]attribute marks a field as mandatory. You can provide aFixAction(method name) andFixActionName(display name) to allow users to automatically fix missing references via a button in the inspector.[Required] public Material material; [Required(FixAction = nameof(FixTarget), FixActionName = "Assign self")] public Transform target; private void FixTarget() { target = GetComponent<Transform>(); }Show non-serialized properties with ShowInInspector
mainUse the
[ShowInInspector]attribute to display properties in the Unity Inspector that are not normally serialized (such as private fields, read-only properties, or properties with custom getters/setters).private float _field; [ShowInInspector] private bool _myToggle; [ShowInInspector] public float ReadOnlyProperty => _field; [ShowInInspector] public float EditableProperty { get => _field; set => _field = value; }Automatically fetch references with RequiredGet
mainThe
[RequiredGet]attribute automatically searches for and assigns a reference during inspector interaction.InParents = true: Searches up the hierarchy.InChildren = true, IncludeSelf = false: Searches down the hierarchy excluding the current object.
[RequiredGet] public Transform myTransform; [RequiredGet(InParents = true)] public Animator animator; // Search for any Animator in parents [RequiredGet(InChildren = true, IncludeSelf = false)] public MeshRenderer[] childrenMeshes; // Search all meshes in childrenDisplay complex types inline with InlineProperty
mainThe
[InlineProperty]attribute allows you to display the fields of a[Serializable]class directly within the inspector of the parent object, rather than using a foldout.public MinMax rangeFoldout; [InlineProperty(LabelWidth = 40)] public MinMax rangeInline; [Serializable] public class MinMax { public int min; public int max; }