bool TestCondition( System.Object targetObject, TypeDescription td )
bool TestCondition( SerializedObject so )

book_4_sparkGenerated
code_blocksInput

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 editor scripting to conditionally display properties in the inspector based on the state of other properties.

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.

This method is virtual, allowing it to be overridden in derived classes if custom behavior is needed.

Example

public class MyComponent : Component
{
    [ShowIf("IsVisible")]
    public int VisibleProperty;

    public bool IsVisible;

    public void CheckVisibility()
    {
        ShowIfAttribute showIf = new ShowIfAttribute();
        bool isConditionMet = showIf.TestCondition(this, new TypeDescription(typeof(MyComponent)));
        // Use isConditionMet to determine if VisibleProperty should be shown
    }
}