arimger/Unity-Editor-Toolbox

Conditional drawers not considering null as a valid comparison

Vacui opened this issue · 2 comments

Vacui commented

If I try to Hide/Show/Enable/Disable a parameter based on the null value of another, the console throw a warning like this:
Invalid comparison input: source:UnityEngine.GameObject, target:, method:Equal.

The code that originated this log message is this:

using UnityEngine;

public class testScript : MonoBehaviour
{
    public GameObject var1;
    [ShowIf(nameof(var1), null)]
    public string var2;
}

I tried on a clean project with the same Unity version (2018.4.24f1), but the issue remains.
Let me know if it is an unsurpassable structural thing.

Try "false". UnityEngine.Object has an overload for the bool operator to indicate if the native object exist.

Vacui commented

It works, thx really much for your help.