Description
The TestCondition
method in the ShowIfAttribute
class is used to determine whether a specific condition is met for a given object. This method is typically used in the context of the Editor Inspector to decide whether a property should be displayed based on the value of another property within the same class.
Usage
To use the TestCondition
method, you need to pass the target object and a TypeDescription
instance as parameters. The method will return a boolean value indicating whether the condition specified by the ShowIfAttribute
is satisfied.
Example
// Example usage of ShowIfAttribute.TestCondition
public class MyComponent : Component
{
[ShowIf("IsVisible", true)]
public int VisibleProperty { get; set; }
public bool IsVisible { get; set; }
public void CheckVisibility()
{
ShowIfAttribute showIfAttribute = new ShowIfAttribute();
bool shouldShow = showIfAttribute.TestCondition(this, new TypeDescription(typeof(MyComponent)));
// Use the result to determine if the property should be shown
}
}