Code Monkey home page Code Monkey logo

tri-inspector's Introduction

Tri Inspector Github license Unity 2020.3 GitHub package.json version openupm

Advanced inspector attributes for Unity

Tri-Inspector-Demo

How to Install

Library distributed as git package (How to install package from git URL)
Git URL: https://github.com/codewriter-packages/Tri-Inspector.git

Localization package dependency
Tri Inspector automatically installs Localization package as dependency.
If you are not using localization package and do not want to install it, you can install a stub package instead.
Git URL: https://github.com/codewriter-packages/Unity-Localization-Stub-for-Tri-Inspector.git

Roadmap GitHub Repo stars

Each star ★ on the project page brings new features closer. You can suggest new features in the Discussions.

Samples

TriInspector has built-in samples at Tools/Tri Inspector/Samples menu. Samples

Attributes

Misc

ShowInInspector

Shows non-serialized property in the inspector.

ShowInInspector

private float _field;

[ShowInInspector]
private bool _myToggle;

[ShowInInspector]
public float ReadOnlyProperty => _field;

[ShowInInspector]
public float EditableProperty
{
    get => _field;
    set => _field = value;
}

HideReferencePicker

Tri Inspector by default shows a polymorphic type picker for [SerializeReference] and [ShowInInspector]. It can be hidden with a [HideReferencePicker] attribute.

HideReferencePicker

[SerializeReference]
public MyReferenceClass clazz1 = new MyReferenceClass();

[SerializeReference, HideReferencePicker]
public MyReferenceClass clazz2 = new MyReferenceClass();

[ShowInInspector, HideReferencePicker]
public MyReferenceClass Clazz3 { get; set; } = new MyReferenceClass();

[Serializable]
public class MyReferenceClass
{
    public int inner;
}

PropertyOrder

Changes property order in the inspector.

PropertyOrder

public float first;

[PropertyOrder(0)]
public float second;

ReadOnly

Makes property non-editable in the inspector.

ReadOnly

[ReadOnly]
public Vector3 vec;

OnValueChanged

Invokes callback on property modification.

[OnValueChanged(nameof(OnMaterialChanged))]
public Material mat; 

private void OnMaterialChanged()
{
    Debug.Log("Material changed!");
}

HideMonoScript

Hides the default Script property in the inspector.

[HideMonoScript]
public class NewBehaviour : MonoBehaviour
{
}

Validation

Tri Inspector has some builtin validators such as missing reference and type mismatch error. Additionally you can mark out your code with validation attributes or even write own validators.

Builtin-Validators

Required

Required

[Required]
public Material material;

[Required(FixAction = nameof(FixTarget), FixActionName = "Assign self")]
public Transform target;

private void FixTarget()
{
    target = GetComponent<Transform>();
}

ValidateInput

ValidateInput

[ValidateInput(nameof(ValidateTexture))]
public Texture tex;

private TriValidationResult ValidateTexture()
{
    if (tex == null) return TriValidationResult.Error("Tex is null");
    if (!tex.isReadable) return TriValidationResult.Warning("Tex must be readable");
    return TriValidationResult.Valid;
}

InfoBox

InfoBox

[Title("InfoBox Message Types")]
[InfoBox("Default info box")]
public int a;

[InfoBox("None info box", TriMessageType.None)]
public int b;

[InfoBox("Warning info box", TriMessageType.Warning)]
public int c;

[InfoBox("Error info box", TriMessageType.Error)]
public int d;

[InfoBox("$" + nameof(DynamicInfo), visibleIf: nameof(VisibleInEditMode))]
public Vector3 vec;

private string DynamicInfo => "Dynamic info box: " + DateTime.Now.ToLongTimeString();

private bool VisibleInEditMode => !Application.isPlaying;

AssetsOnly

AssetsOnly

[AssetsOnly]
public GameObject obj;

SceneObjectsOnly

SceneObjectsOnly

[SceneObjectsOnly]
public GameObject obj;

Decorators

Dropdown

Dropdown

[Dropdown(nameof(intValues))]
public int numberDropdown = 123;

[Dropdown(nameof(GetVectorValues))]
public Vector3 vectorDropdown;

private int[] intValues = {1, 2, 3, 4, 5};

private IEnumerable<TriDropdownItem<Vector3>> GetVectorValues()
{
    return new TriDropdownList<Vector3>
    {
        {"Zero", Vector3.zero},
        {"One/Forward", Vector3.forward},
        {"One/Backward", Vector3.back},
    };
}

Scene

Scene

[Scene] public string scene;

InlineEditor

InlineEditor

[InlineEditor]
public Material mat;

DisplayAsString

DisplayAsString

[DisplayAsString]
public string[] collection = {"hello", "world"};

Styling

Title

Title

[Title("My Title")]
public string val;

[Title("$" + nameof(_myTitleField))]
public Rect rect;

[Title("$" + nameof(MyTitleProperty))]
public Vector3 vec;

[Title("Button Title")]
[Button]
public void MyButton()
{
}

private string _myTitleField = "Serialized Title";

private string MyTitleProperty => DateTime.Now.ToLongTimeString();

HideLabel

HideLabel

[Title("Wide Vector")]
[HideLabel]
public Vector3 vector;

[Title("Wide String")]
[HideLabel]
public string str;

LabelText

LabelText

[LabelText("Custom Label")]
public int val;

[LabelText("$" + nameof(DynamicLabel))]
public Vector3 vec;

public string DynamicLabel => DateTime.Now.ToShortTimeString();

LabelWidth

LabelWidth

public int defaultWidth;

[LabelWidth(40)]
public int thin;

[LabelWidth(300)]
public int customInspectorVeryLongPropertyName;

GUIColor

GUIColor

[GUIColor(0.8f, 1.0f, 0.6f)]
public Vector3 vec;

[GUIColor(0.6f, 0.9f, 1.0f)]
[Button]
public void BlueButton() { }

[GUIColor(1.0f, 0.6f, 0.6f)]
[Button]
public void RedButton() { }

Indent

Indent

[Title("Custom Indent")]
[Indent]
public int a;

[Indent(2)]
public int b;

[Indent(3)]
public int c;

[Indent(4)]
public int d;

PropertySpace

PropertySpace

[Space, PropertyOrder(0)]
public Vector3 vecField;

[ShowInInspector, PropertyOrder(1)]
[PropertySpace(SpaceBefore = 10, SpaceAfter = 30)]
public Rect RectProperty { get; set; }

[PropertyOrder(2)]
public bool b;

PropertyTooltip

PropertyTooltip

[PropertyTooltip("This is tooltip")]
public Rect rect;

[PropertyTooltip("$" + nameof(DynamicTooltip))]
public Vector3 vec;

public string DynamicTooltip => DateTime.Now.ToShortTimeString();

InlineProperty

InlineProperty

public MinMax rangeFoldout;

[InlineProperty(LabelWidth = 40)]
public MinMax rangeInline;

[Serializable]
public class MinMax
{
    public int min;
    public int max;
}

Collections

ListDrawerSettings

ListDrawerSettings

[ListDrawerSettings(Draggable = true,
                    HideAddButton = false,
                    HideRemoveButton = false,
                    AlwaysExpanded = false)]
public List<Material> list;

[ListDrawerSettings(Draggable = false, AlwaysExpanded = true)]
public Vector3[] vectors;

TableList

TableList

[TableList(Draggable = true,
           HideAddButton = false,
           HideRemoveButton = false,
           AlwaysExpanded = false)]
public List<TableItem> table;

[Serializable]
public class TableItem
{
    [Required]
    public Texture icon;
    public string description;

    [Group("Combined"), LabelWidth(16)]
    public string A, B, C;

    [Button, Group("Actions")]
    public void Test1() { }

    [Button, Group("Actions")]
    public void Test2() { }
}

Conditionals

ShowIf

ShowIf

public Material material;
public bool toggle;
public SomeEnum someEnum;

[ShowIf(nameof(material), null)]
public Vector3 showWhenMaterialIsNull;

[ShowIf(nameof(toggle))]
public Vector3 showWhenToggleIsTrue;

[ShowIf(nameof(toggle), false)]
public Vector3 showWhenToggleIsFalse;

[ShowIf(nameof(someEnum), SomeEnum.Two)]
public Vector3 showWhenSomeEnumIsTwo;

public enum SomeEnum { One, Two, Three }

HideIf

public bool visible;

[HideIf(nameof(visible))]
public float val;

EnableIf

public bool visible;

[EnableIf(nameof(visible))]
public float val;

DisableIf

public bool visible;

[DisableIf(nameof(visible))]
public float val;

HideInPlayMode / ShowInPlayMode

[HideInPlayMode] [ShowInPlayMode]

DisableInPlayMode / EnableInPlayMode

[DisableInPlayMode] [EnableInPlayMode]

HideInEditMode / ShowInEditMode

[HideInEditMode] [ShowInEditMode]

DisableInEditMode / EnableInEditMode

[DisableInEditMode] [EnableInEditMode]

Buttons

Button

Button

[Button("Click me!")]
private void Button() => Debug.Log("Button clicked!");

[Button(ButtonSizes.Large)]
private void ButtonWithParameters(Vector3 vec, string str = "default value")
{
    Debug.Log($"Button with parameters: {vec} {str}");
}

EnumToggleButtons

EnumToggleButtons

[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,
}

Debug

ShowDrawerChain

ShowDrawerChain

[ShowDrawerChain]
[Indent]
[PropertySpace]
[Title("Custom Title")]
[GUIColor(1.0f, 0.8f, 0.8f)]
public Vector3 vec;

Groups

Properties can be grouped in the inspector using the Group attribute.

[Group("one")] public float a;
[Group("one")] public float b;

[Group("two")] public float c;
[Group("two")] public float d;

public float e;

If you have a lot of properties and group attributes take up too much space, then you can combine multiple properties at once using the GroupNext attribute.

[GroupNext("one")]
public float a;
public float b;

[GroupNext("two")]
public float c;
public float d;

[UnGroupNext]
public float e;

Box Group

BoxGroup

[DeclareBoxGroup("box", Title = "My Box")]
public class BoxGroupSample : ScriptableObject
{
    [Group("box")] public int a;
    [Group("box")] public bool b;
}

Foldout Group

FoldoutGroup

[DeclareFoldoutGroup("foldout", Title = "$" + nameof(DynamicTitle))]
public class FoldoutGroupSample : ScriptableObject
{
    [Group("foldout")] public int a;
    [Group("foldout")] public bool b;
    
    public string DynamicTitle => "My Foldout";
}

Toggle Group

ToggleGroup

[DeclareToggleGroup("toggle", Title = "$" + nameof(DynamicTitle))]
public class ToggleGroupSample : ScriptableObject
{
    [Group("toggle")] public bool enabled;
    [Group("toggle")] public int a;
    [Group("toggle")] public bool b;
    
    public string DynamicTitle => "My Toggle";
}

Tab Group

TabGroup

[DeclareTabGroup("tabs")]
public class TabGroupSample : ScriptableObject
{
    [Group("tabs"), Tab("One")] public int a;
    [Group("tabs"), Tab("Two")] public float b;
    [Group("tabs"), Tab("Three")] public bool c;
}

Horizontal Group

HorizontalGroup

[DeclareHorizontalGroup("vars")]
public class HorizontalGroupSample : ScriptableObject
{
    [Group("vars")] public int a;
    [Group("vars")] public int b;
    [Group("vars")] public int c;
}

Vertical Group

VerticalGroup

[DeclareHorizontalGroup("horizontal")]
[DeclareVerticalGroup("horizontal/vars")]
[DeclareVerticalGroup("horizontal/buttons")]
public class VerticalGroupSample : ScriptableObject
{
    [Group("horizontal/vars")] public float a;
    [Group("horizontal/vars")] public float b;

    [Button, Group("horizontal/buttons")]
    public void ButtonA() { }

    [Button, Group("horizontal/buttons")]
    public void ButtonB() { }
}

Integrations

Odin Inspector

Tri Inspector is able to work in compatibility mode with Odin Inspector. In this mode, the primary interface will be drawn by the Odin Inspector. However, parts of the interface can be rendered by the Tri Inspector.

In order for the interface to be rendered by Tri instead of Odin, it is necessary to mark classes with [DrawWithTriInspector] attribute.

Alternatively, you can mark the entire assembly with an attribute [assembly:DrawWithTriInspector] to draw all types in the assembly using the Tri Inspector.

Odin Validator

Tri Inspector is integrated with the Odin Validator so all validation results from Tri attributes will be shown in the Odin Validator window.

Odin-Validator-Integration

License

Tri-Inspector is MIT licensed.

tri-inspector's People

Contributors

alexejhero avatar govorunb avatar hoshiza avatar lunalunachi avatar tsfreddie avatar vanifatovvlad avatar xarpen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tri-inspector's Issues

Exception: 'ReorderableList' does not contain a definition for 'ClearCacheRecursive'

WTR:

  1. Download Tri-Inspector into your project (tested on the latest Unity 2021.3.5f1)
  2. Run Installer.unitypackage
  3. Discover exception Assets/Tri-Inspector/Unity.InternalAPIEditorBridge.012/ReorderableListProxy.cs(26,18): error CS1061: 'ReorderableList' does not contain a definition for 'ClearCacheRecursive' and no accessible extension method 'ClearCacheRecursive' accepting a first argument of type 'ReorderableList' could be found (are you missing a using directive or an assembly reference?)

Got error when click on folder/item

Describe the bug

TriAssetImporterEditor.OnInspectorGUI must call ApplyRevertGUI to avoid unexpected behaviour.
UnityEditor.AssetImporters.AssetImporterEditor:OnDisable ()
TriInspector.TriAssetImporterEditor:OnDisable () (at ./Library/PackageCache/com.codewriter.triinspector@04ad48abec/Editor/TriEditor.cs:28)

Expected behavior
No error

Screenshots
image

Desktop:
Unity version:
Tri Inspector version:

Does not work for children of NetworkBehaviour

Describe the bug
For classes inherited from Unity.Netcode.NetworkBehaviour no attributes are drawn.

For other classes, even in the same assembly, even inherited from other abstract classes (which in turn are inherited from MonoBehaviour) works fine.

Maybe the error is not connected with NetworkBehaviour, or Unity did some nasty things there, or the error is mine, don't know :)

Expected behavior
Drawn attributes, as usual.

Code Sample

using TriInspector;
using Unity.Netcode;
using UnityEngine;

public class Test: NetworkBehaviour
{
    [SerializeField]
    private bool isSynced = false;

    [InfoBox(
        "oh no",
        TriMessageType.Warning
    )]
    [SerializeField]
    [EnableIf(nameof(isSynced))]
    private int syncActionType;
}

Screenshots
image

Desktop: Windows 11
Unity version: 2023.2.4f1
Tri Inspector version: 1.13.2

Collections do not display element index.

Describe the bug
Collections such as List and Array do not show the index of each element. Problem may exists for other colllection types as well.

Expected behavior
Show indexes to elements.

Code Sample

public class NoIndexDemo : MonoBehaviour
{
    public List<int> _lst;
    public int[] _arry;
}

Screenshots
image

Unity version: 2019, 2020, 2021 LTS
Tri Inspector version: 1.13.0

issue with displaying Dictionary types

Describe the bug
The TriInspector probably doesn't serialize and support dictionaries, but for some reason it trys. and as a result, a broken inspector will be shown for them

Expected behavior
Either don't show them or show them properly

Code Sample

public Dictionary<string, Object> listeners;

Screenshots
image

Desktop: Windows 10
Unity version: 2021.2.13f1
Tri Inspector version: 1.9.5

Bug draw custom property type in unity 2022.2

Describe the bug
Dupplicate draw field when attach value for field after attach component to GameObject.

Wrong positon draw field

I was check with Unity 2021.3 and it still work correctly

Expected behavior

  • Attach script to GameObject
  • Change the value of field

Code Sample
Create class player look like

public class Player : MonoBehaviour
{
    public string id;
}

And create CustomPropertyDrawer for it

[CustomPropertyDrawer(typeof(Player))]
public class PlayerPropertyEditor : PropertyDrawer
{
    private SerializedObject _serializedObject;

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);
        var targetObject = property.objectReferenceValue;
        if (targetObject == null)
        {
            EditorGUI.PropertyField(position, property, label);
            EditorGUI.EndProperty();
            return;
        }

        if (_serializedObject == null || _serializedObject.targetObject != targetObject) _serializedObject = new SerializedObject(targetObject);

        _serializedObject.UpdateIfRequiredOrScript();

        var rect = position;
        var labelRect = position;
        labelRect.width = position.width * 0.4f;
        property.isExpanded = EditorGUI.Foldout(labelRect, property.isExpanded, new GUIContent(""), true);

        if (property.isExpanded)
        {
            //Draw property on the full width
            rect.width = position.width;
            EditorGUI.PropertyField(rect, property, label);

            EditorGUI.indentLevel++;
            GUILayout.BeginVertical(GUI.skin.box);
            DrawInspectorExcept(_serializedObject, new[] {"m_Script"});
            GUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }

        _serializedObject.ApplyModifiedProperties();
        EditorGUI.EndProperty();
    }

        public static void DrawInspectorExcept(SerializedObject serializedObject, string[] fieldsToSkip)
        {
            serializedObject.Update();
            var prop = serializedObject.GetIterator();
            if (prop.NextVisible(true))
            {
                do
                {
                    if (fieldsToSkip.Any(prop.name.Contains)) continue;

                    EditorGUILayout.PropertyField(serializedObject.FindProperty(prop.name), true);
                } while (prop.NextVisible(false));
            }

            serializedObject.ApplyModifiedProperties();
        }
}

Now can test with sample demo

using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    public Player player;
    public float damage;
}

Screenshots
image

image

Desktop: Windows 11
Unity version: 2022.2.11f1
Tri Inspector version: 1.10.0

Serialized property bug

Describe the bug

For serialized properties changing fields with reference types (AnimationCurve, Gradient) doesn't mark object as dirty

Expected behavior
After changing values object marks as dirty

Code Sample

Changing values inside testField works as intended, but not for TestProperty

public class CurveTest : MonoBehaviour
{
    public NestedReferenceTest testField;

    [ShowInInspector]
    [InlineProperty]
    [HideLabel]
    [PropertySpace]
    public NestedReferenceTest TestProperty
    {
        get => testField;
        set => testField = value;
    }
}

[Serializable]
public class NestedReferenceTest
{
    public AnimationCurve curve;
    public Gradient gradient;
    public float floatValue;
}

The problem is in the TriValue.SmartValue I suppose - comparer for reference values always returns true

        [PublicAPI]
        public T SmartValue
        {
            get => (T) Property.Value;
            set
            {
                if (Property.Comparer.Equals(Property.Value, value))
                {
                    return;
                }

                Property.SetValue(value);
            }
        }

Desktop: Windows 10
Unity version: 2022.3.16f1
Tri Inspector version: 1.13.2

[TextArea] not working on 2022.1.0b10.2818 with TriInspector installed

Discussed in https://github.com/codewriter-packages/Tri-Inspector/discussions/24

Originally posted by piscopancer July 15, 2022
textfield of a string property becomes invisible when textarea attribute is assigned. I have a large poem to write in inspector though. my version is 1.6.0. I have tried it with different versions of Unity starting from 2021s and nowhere does it seem working. Can you check it out on your own bcs I still doubt that it is a 100% my setup error. ☺

BTW what I mean by not working is that there are 2 cases in one of which the whole textField of a string in inspector is invisible and in another case that TextArea sliders on the right truly appear BUT the textField remains invisible anyway.

Error when installing from upm

Describe the bug

Error when installing from upm

Expected behavior

Installed without error

Screenshots

image

Desktop: Windows 10
Unity version: 2020.3.38f1 and 2021.3.9f1
Tri Inspector version: 1.9.1

ReorderableList conflict in 2020.3.22f1+

Describe the bug

On Unity 2020.3.22f1 (and assuming later versions as well)

On install:
Library\PackageCache\com.codewriter.triinspector@692dfb6\Unity.InternalAPIEditorBridge.012\ReorderableListProxy.cs(42,18): error CS1061: 'ReorderableList' does not contain a definition for 'InvalidateCacheRecursive' and no accessible extension method 'InvalidateCacheRecursive' accepting a first argument of type 'ReorderableList' could be found (are you missing a using directive or an assembly reference?)

Expected behavior

No errors should present.

Code Sample

To fix, in ReorderableListProxy:41, remove the bit that says UNITY_2020_3

MeshFilter inspector is not drawn

WTR:

  1. Create empty project (tested on Unity 2021.3.5f1)
  2. Create any default 3d object (for example 3D Object / Cube).
  3. Select created game object and see that MeshFilter inspector is drawn (you can see and edit Mesh field).
  4. Add Tri-Inspector package and run Installer.unitypackage
  5. Discover that MeshFilter inspector is not drawn anymore (you can see only caption).

Note: You can still see Mesh field if inspector is in the debug mode. If you add serialized Mesh field to your scripts it is visible in the inspector, so looks like the issue is with MeshFilter component only.

EnumToggleButtons not working with enum flags

Describe the bug
The attribute, [EnumToggleButtons], does not support flagged enums, despite the images showing it in the read me. When clicking on an enum, it will remove all other values and only set the value to the recently selected enum.

Expected behavior
Multiple flags can be applied at once.

Code Sample
The problem is in EnumToggleButtonsDrawer -> OnGUI, where the code on line 75 overwrites the property value with the changed value. When there is a flag, it should only toggle the bit values. I tried modifying the code to get it to work demonstrated with the yellow highlighting in the image below, and it seems to work. There are probably cleaner ways to do it, but this solves it for me for now.
image

Desktop: Windows 10
Unity version: 2020.3.25f1
Tri Inspector version: 1.9.6

Script field is missing in the inspector

Describe the bug
After adding Tri-Inspector to a Unity project the script field is no longer shown on components in the inspector. Is it possible to show it again?

Screenshots
Without Tri-Inspector:
image

With Tri-Inspector:
image

TableList is not draggable

Describe the bug
TableList is not draggable. Try "Tri Samples" have the same error.

Code Sample

[TableList(Draggable = true,
            HideAddButton = false,
            HideRemoveButton = false,
            AlwaysExpanded = false
)]

Unity version: 2021.3.7f1
Tri Inspector version: 0.18

FieldValueResolver not correct when use Condition for Array

Describe the bug
Bug condition with array not empty, seem to be error by _valueGetter(property, targetIndex) return parent not correct

Expected behavior
Draw aray element correctly without error

Code Sample

public bool isShow;

[HideIf(nameof(isShow))] public List<int> itemIds = new List<int>();

Screenshots
image

image

Desktop:
Unity version:
Tri Inspector version:

[Request] Add compared value to ShowIf, HideIf, EnableIf, DisableIf

public SomeEnum someEnum;
public bool someBool;

[ShowIf(nameof(someEnum), SomeEnum.Two)]
public bool val;

[ShowIf(nameof(someBool), true)] // Same as [ShowIf(nameof(someBool))]
public float f1;

[ShowIf(nameof(someBool), false)]
public float f2;

public enum SomeEnum { One, Two }

[Unity 2019] No overload for method 'DoAddButton' takes 2 arguments

Describe the bug
Installing tri inspector results in this error in the console:

Library\PackageCache\com.codewriter.triinspector@0e23ca4\Unity.InternalAPIEditorBridge.012\ReorderableListProxy.cs(66,31): error CS1501: No overload for method 'DoAddButton' takes 2 arguments

Unity version: 2019.4.36f1
Tri Inspector version: 0e23ca4 (1.13.2)

ReadOnly doesn't work with InlineEditor

Describe the bug
A serialized property in a class with the [ReadOnly] attribute becomes editable when it is declared with the [InlineEditor]

Expected behavior

The [ReadOnly] attribute must be active for all time.
Code Sample

// 

[Serializable]
public class Data
{
  [SerializedField,ReadOnly]
  private float a; // a is not editable in inspector here :)
}
public class Test : MonoBehaviour
{
  [SerializedField,InlineEditor]
  private Data data; // data.a become editable in inspector here :(
}

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->

**Desktop:** <!-- e.g. Windows 11 -->
**Unity version:** <!-- e.g. 2021.3.33f1 -->
**Tri Inspector version:** <!-- e.g. 1.13.2 -->

List inside a Box Group has no spacing at the top.

Describe the bug
If you declare a box group and then put a list inside it, the list is drawn hard up against the bottom of the box title.

Expected behavior
Expected to be a gap

Screenshots
image

Desktop: Windows 10
Unity version: 2022.1.24
**Tri Inspector version: 1.10

unity [Range] attribute don't display correctly when using Tri Inspector

Describe the bug
Unity [Range] attribute don't show correctly with Tri inspector, and float field exceed inspector width.
When part of an horizontal group, sliders width get wrong and can overlap with label.
Expected behavior
[Range] attribute show correctly in all cases

Code Sample

using TriInspector;
using UnityEngine;

[DeclareBoxGroup("Test")]
[DeclareHorizontalGroup("TestHorizontal")]
public class TestComponent : MonoBehaviour
{
    [Range(0, 1)]
    public float simpleRange;

    [Group("TestHorizontal"), Range(0, 1)]
    public float horizontalRange1;
    [Group("TestHorizontal"), Range(0, 1)]
    public float horizontalRange2;
}

Screenshots
image

Desktop: Windows 11
Unity version: 2022.3.11
Tri Inspector version: 1.13.2

Conflict with EasyButtons causes TriInspector to not draw

Describe the bug

When a project has EasyButtons installed via PackageManager (https://github.com/madsbangh/EasyButtons) when TriInspector is installed, it would appear that TriInspector does not draw. I am guessing that EasyButtons is also drawing the inspector and does so after or in conflict with TriInspector.

EasyButtons is an older package which has a [Button] attribute as well, so this might be something that comes up for other potential users of TriInspector.

Expected behavior

TriInspector should draw.

Code Sample

To fix, uninstall EasyButtons before installing TriInspector. Then replace using EasyButtons with using TriInspector and in most cases the attribute signature remains the same.

// 

Screenshots

Desktop:
Unity version:
Tri Inspector version:

Serializable structs with explicit layout

Describe the bug
Can`t edit area of effects values
Expected behavior
able to edit area of effect values

Code Sample



[Serializable]
[StructLayout(LayoutKind.Explicit)]
public struct GameplayAction
{
    [FieldOffset(0)]
    public GameplayActionType Type;

    [FieldOffset(4)]
    [ShowIf(nameof(Type), GameplayActionType.SpawnProjectile)]
    public SpawnProjectileAction SpawnProjectile;

    [FieldOffset(4)]
    [ShowIf(nameof(Type), GameplayActionType.ApplyEffect)]
    public ApplyEffectAction ApplyEffect;

    [FieldOffset(4)]
    [ShowIf(nameof(Type), GameplayActionType.ApplyAreaOfEffect)]
    public AreaOfEffectShape AreaOfEffect;

    [FieldOffset(4)]
    [ShowIf(nameof(Type), GameplayActionType.SpawnAreaOfEffect)]
    public SpawnAreaOfEffectAction SpawnAreaOfEffect;
}
// 

Screenshots

Desktop: Windows 11
**Unity version: 2020.3.35f1
image

Tri Inspector version: 1.1.01

Compile errors on new install with odin 2.1.13.0 on unity 2021.3.38f1

Describe the bug
Compile errors on new install with odin 2.1.13.0 on unity 2021.3.38f1

Expected behavior
no compile errors

Library\PackageCache\com.codewriter.triinspector@0c5b8f4480\Editor.Integrations\Odin\OdinObjectValidator.cs(21,30): error CS0115: 'OdinObjectValidator<T>.CanValidateProperty(InspectorProperty)': no suitable method found to override
Library\PackageCache\com.codewriter.triinspector@0c5b8f4480\Editor.Integrations\Odin\OdinObjectValidator.cs(49,33): error CS0115: 'OdinObjectValidator<T>.Validate(ValidationResult)': no suitable method found to override
Library\PackageCache\com.codewriter.triinspector@0c5b8f4480\Editor.Integrations\Odin\OdinObjectValidator.cs(11,18): error CS0534: 'OdinObjectValidator<T>' does not implement inherited abstract member 'ValueValidator<T>.Validate(T, ValidationResult)'

Desktop: Windows 10
Unity version: 2021.3.38f1
Tri Inspector version: v1.14.0

After install has compile errors

Clear Unity 2021.3.8 URP project. It may be something with assemblies.

Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\InlineEditorElement.cs(2,7): error CS0246: The type or namespace name 'TriInspectorUnityInternalBridge' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\TriBuiltInPropertyElement.cs(1,7): error CS0246: The type or namespace name 'TriInspectorUnityInternalBridge' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\TriInfoBoxElement.cs(2,7): error CS0246: The type or namespace name 'TriInspectorUnityInternalBridge' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\TriListElement.cs(3,7): error CS0246: The type or namespace name 'TriInspectorUnityInternalBridge' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\TriPropertyElement.cs(2,7): error CS0246: The type or namespace name 'TriInspectorUnityInternalBridge' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Utilities\TriManagedReferenceGui.cs(4,7): error CS0246: The type or namespace name 'TriInspectorUnityInternalBridge' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\TriBuiltInPropertyElement.cs(10,26): error CS0246: The type or namespace name 'PropertyHandlerProxy' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.codewriter.triinspector@a1fd95dc2e\Editor\Elements\TriBuiltInPropertyElement.cs(16,13): error CS0246: The type or namespace name 'PropertyHandlerProxy' could not be found (are you missing a using directive or an assembly reference?)

[Request] Add TableList attribute

TableList

[TableList] public List<TableItem> table;

[Serializable]
public class TableItem
{
    public Texture icon;
    public string description;

    [Group("Combined"), LabelWidth(16)]
    public string A, B, C;

    [Button, Group("Actions")]
    public void Test1() { }

    [Button, Group("Actions")]
    public void Test2() { }
}

No GUI Implemented in Unity 2022

Describe the bug
When using CreatePropertyGUI() for custom PropertyDrawers, a No GUI Implemented error is displayed.

Expected behavior
A custom PropertyDrawer should be displayed.

Code Sample

using UnityEngine;

public enum IngredientUnit { Spoon, Cup, Bowl, Piece }

// Custom serializable class
[Serializable]
public class Ingredient
{
    public string name;
    public int amount = 1;
    public IngredientUnit unit;
}

public class Recipe : MonoBehaviour
{
    public Ingredient potionResult;
    public Ingredient[] potionIngredients;
}

[CustomPropertyDrawer(typeof(Ingredient))]
public class IngredientDrawerUIE : PropertyDrawer
{
    public override VisualElement CreatePropertyGUI(SerializedProperty property)
    {
        // Create property container element.
        var container = new VisualElement();

        // Create property fields.
        var amountField = new PropertyField(property.FindPropertyRelative("amount"));
        var unitField = new PropertyField(property.FindPropertyRelative("unit"));
        var nameField = new PropertyField(property.FindPropertyRelative("name"), "Fancy Name");

        // Add fields to the container.
        container.Add(amountField);
        container.Add(unitField);
        container.Add(nameField);

        return container;
    }
}

Screenshots
image

Desktop: Windows 11
Unity version: 2022.3.4
Tri Inspector version: 1.9.6

Serialized Color32 fields are not visible in the inspector

WTR:

  1. Create empty project (tested on Unity 2021.3.5f1)
  2. Create script with serialized Color32 field, for example [SerializeField] private Color32 _color;
  3. Add this script to game object and see that field "Color" is visible in the inspector.
  4. Add Tri-Inspector package and run Installer.unitypackage
  5. Discover that field "Color" is not visible in the inspector anymore.

Note: Field is still visible if the inspector is in the debug mode.

Visual bug: Class instance "arrow sign" in the BoxGroup

The foldout arrow is outside BoxGroup (probably any group tho)

Expected to be placed little bit to the right (with offset of about 20-50 pixels idk)

Screenshots
image

Windows 10
2022.1.0b10.2818
1.8.0

THE SOLUTION FOR THIS MAY BE:

image
so I have simply added Indent like this

 [SerializeField, Group("Presets"), Indent(1)] CameraPreset presetMenu, presetGuns, presetCharacter;

and it worked nicely.
So can you somehow automate/fix/solve it?

Hashsets are shown as empty inline properies

Describe the bug
Hashsets are shown wrongly

Expected behavior
Hashstes shouldn't be shown in inspector, or should be shown properly

Code Sample

public HashSet<string> registeredChannels

Screenshots
image

Desktop: Windows 10
Unity version: 2021.2.13f1
Tri Inspector version: 1.9.6

RectOffset draw not correctly

Describe the bug
Properties with data type RectOffset are not drawn correctly outside the inspector

Expected behavior
Draw full properties of class RectOffset

Like this

image

Code Sample

using UnityEngine;

public class Demo : MonoBehaviour
{
    public RectOffset offset;
}

Screenshots
image

Desktop:
Unity version:
Tri Inspector version:

InfoBox doesn't update visibility immediately if showif condition changes

Describe the bug
Add an InfoBox attribute to a field.
Give the InfoBox a 'showif' parameter
Observe showif is initially respected.
Change state such that showif result would change
Observe the visibility of the InfoBox does not change until you navigate away or cause some other update of the inspector

Expected behavior
Changing the state such that the showif result would change should update visibility immediately.

Code Sample

[InfoBox("Some message", TriMessageType.Info, "$SomeConditionCheck")]
private int field;

Desktop: Windows 10
Unity version: 2021.1.24
Tri Inspector version: 1.10.1

Unable to add package in Unity 2020.3.48f1

Describe the bug
I wanted to replace Odin Inspector with Tri-Inspector in one of my open-source sample.
I followed install instruction from Readme, but bump with error:

[Package Manager Window] Unable to add package [https://github.com/codewriter-packages/Tri-Inspector.git]:
  Package com.codewriter.triinspector@https://github.com/codewriter-packages/Tri-Inspector.git has invalid dependencies or related test packages:
    com.unity.localization (dependency): Package [[email protected]] cannot be found
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Is Tri-Inspector compatible only with Unity 2021+?

Expected behavior
I expected everything will be going smooth as butter.

Screenshot
image

Desktop: Windows 10 LTSC
Unity version: 2020.3.48f1
Tri Inspector version: Latest

Dropdown attribute not updating Object nor applying to it properly/on time

Describe the bug
Dropdown attribute not working as expected. it updates on specific timing that's not on par with the serializableObejct.Apply...() nor serializableObject.Update(). so it neither receives data on time nor applies it on time

Expected behavior
update like other (i.e. float) fields

Code Sample
the editor window is here
and the class itself is here (look for word 'dropdown')

Screenshots
here's a video demonstrating the problem

out.mp4

Desktop: Windows 10
Unity version: 2021.2.13f1
Tri Inspector version: 1.9.7

Group content box not draw correctly.

Describe the bug
i expect it should have body box like in screenshot in readme. but after i try, it did not have box on content. so i think it is a bug?

Code Sample
From Tri-inspector sample code.

using UnityEngine;
using TriInspector;

[DeclareBoxGroup("box", Title = "My Box")]
[CreateAssetMenu(fileName = "BoxGroupSample", menuName = "BoxGroupSample")]
public class BoxGroupSample : ScriptableObject
{
    [Group("box")] public int a;
    [Group("box")] public bool b;
}

Screenshots
This what i do for test;
devenv_UO49QyNpDY

Expected result: (Having content box)
firefox_6VSRHRjEri

Result: (Not having content box)
Unity_38q94fDX9l

Desktop: Windows 10
Unity version: 2021.3.15f1
Tri Inspector version: 1.9.7

ROADMAP (Github's Star driven)

The following features will be added to the Tri Inspector when the required number of GitHub Repo stars is reached on the project page.

25 ★ - Add EnumToggleButtons attribute [✓ DONE]

35 ★ - Add TableList attribute [✓ DONE]

50 ★ - Add AssetsOnly attributes [✓ DONE]

65 ★ - Add Dropdown attribute [✓ DONE]

85 ★ - Add SceneObjectsOnly attributes [✓ DONE]

100 ★ - Add Scene attributes

[Scene] public string sceneName;
[Scene] public int sceneIndex;

125 ★ - Add ChildGameObjectsOnly attributes

[ChildGameObjectsOnly] public GameObject asset;

165 ★ - Add ParentGameObjectsOnly attributes

[ParentGameObjectsOnly] public GameObject sceneObject;

200 ★ - Add Foldout group

[DeclareFoldoutGroup("demo")]
public class DemoClass {
    [Group("demo")] public bool;
    [Group("demo")] List<Vector3> list;
}

500 ★ - Add TriMenuEditorWindow

Soon

Any suggestions for new attributes? Write them in the comments


UnityEvent don't show their field name in inspector

Describe the bug
UnityEvent don't show their field name in inspector

Expected behavior
UnityEvent show their field name in inspector

Code Sample

{
    public UnityEvent testevent;
    public UnityEvent<float> testevent2;
}

Screenshots

With Tri-Inspector installed
image

Without Tri-Inspector installed:
image

Desktop: Windows 11
Unity version: 2022.3.8
Tri Inspector version: 1.13.1

Reproduced in an empty project.

Inline (Material) Editor does not always display correctly (if new value is assigned to target value)

Describe the bug

When using an attribute
[InlineEditor] public Material mat;
the inline editor sometimes fails to draw (empty, reported height=0) completely in case one assign a new Material to the mat variable from the Inspector.

Reason seems to be:
In InlineEditorElement.cs
When assigning a new value via the inspector the call to
InternalEditorUtilityProxy.SetIsInspectorExpanded is omitted. This call only happens when the element is attached to a panel.
See InlineEditorElement.OnAttachToPanel().
Depending on the Material's state the InlineEditor sometimes does draw. Especially if you switch to a different MonoBehaviour and back.

Possible Fix:

public override void OnGUI(Rect position)
{
...
    if (_editor == null && shouldDrawEditor && _property.Value is Object obj && obj != null)
    {
        _editor = Editor.CreateEditor(obj);
        if (obj != null && !InternalEditorUtilityProxy.GetIsInspectorExpanded(obj))
        {
             InternalEditorUtilityProxy.SetIsInspectorExpanded(obj, true);
        }
    }
... 

Desktop:
Windows 10
Unity version:
2022.3.10f1
Tri Inspector version:
1.13.2

GuiSkin is broken when used with TriInspector

Describe the bug
When i create a new guiskins
Unity GUISkins are not drawn correctly on Inspector (Object Serialize, ReorderList)

Expected behavior
Draw the information of the object, the list of the correct GuiSkins file

Screenshots
image

Desktop: Windows 11
Unity version: 2021.3.8f1
Tri Inspector version: 1.9.2

TableList displaying normal list in inspector

I've been trying to get the TableList working with a custom class I've created, but it kept displaying a normal list inspector.
I also tried using the TableList sample to check if that works, but the same applies (as seen in screenshot below).

Screenshots
image

Desktop: Windows 10
Unity version: Unity 2022.1.18f1
Tri Inspector version: 1.10.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.