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

book_4_sparkGenerated
code_blocksInput

Description

The TestCondition method in the HideIfAttribute class is used to determine whether a specific condition is met, based on the properties of a target object. This method is typically used in the context of editor scripting to conditionally hide properties in the inspector based on the value of another property.

Usage

To use the TestCondition method, you need to pass the target object and a TypeDescription instance that describes the property to be tested. The method will return true if the condition specified by the HideIfAttribute is met, otherwise it returns false.

Example

// Example usage of HideIfAttribute.TestCondition
public class MyComponent : Component
{
    [HideIf("IsHidden", true)]
    public int MyProperty { get; set; }

    public bool IsHidden { get; set; }

    public void CheckVisibility()
    {
        HideIfAttribute hideIf = new HideIfAttribute("IsHidden", true);
        bool shouldHide = hideIf.TestCondition(this, new TypeDescription(typeof(MyComponent)));
        // shouldHide will be true if IsHidden is true
    }
}