ShowIf string comparison not working in 2.0.0 as it was in Odin 1.0.6

Issue #389 resolved
Richard Baxter created an issue

The ShowIf attribute seems to not work if comparing strings. Using Unity 5.6.6f2

This was working in 1.0.6.x but seems to not work in 2.0.0.0

Recreation:

  • Fresh project in Unity 5.6.6f2
  • Import Odin 2.0.0.0 from the Asset Store
  • Create C# script "OdinTest"
using Sirenix.OdinInspector;
using UnityEngine;

public class OdinTest : MonoBehaviour
{
    private string comparisonString = "this is the value";


    [ShowIf("comparisonString", "this is the value")]
    [SerializeField]
    private bool shouldBeVisible;
    // this shows in inspector as expected


    [ShowIf("comparisonString", "this is some other value")]
    [SerializeField]
    private bool shouldNotBeVisible;
    // this also shows in inspector whereas in Odin 1.06 it would not (and I'd expect it to not

}
  • Create an object with OdinTest
  • Both fields are visible in inspector Odin Bug.PNG

Comments (3)

  1. mSkull001

    Strings were treated as reference types and compared using null checks instead. I've changed the behaviour for strings, so now this should work as expected.

  2. Richard Baxter reporter

    Fantastic! Are you able to let me know when the fix will hit the asset store? A date if you are able to give but if not, I'll simply wait :)

  3. Log in to comment