Skip to content

Basics

Key Points:

  • Awake Method: Avoid calling InspectMe() from the Awake method, as it won't be effective.
  • Accessibility: Inspect both private and public members without requiring [Serializable] or [SerializedField] attributes.
  • Build Safety: Like Debug.Log, InspectMe() is safe to include in builds. However, it's good practice to remove or comment it out once you're done debugging.
public class MyClass : MonoBehaviour
{
    void Start()
    {
        // Basic inspection of the current object
        this.InspectMe();
    }
}

Info

Just a heads-up: isn't compatible with every type. To get the most out of it, take a moment to look at our Supported and Unsupported Types.

Advanced Inspection Techniques

Custom Naming

When you have multiple instances of the same class, assign custom names to differentiate them in the Tree-View.

// Assign a custom name for easier identification
this.InspectMe("CustomInstanceName");

Inspecting Nested Properties and Expressions

Use InspectMe for in-depth analysis of nested properties and expressions across various development scenarios, extending beyond just UI elements to more intricate aspects of your project.

// Inspecting a nested property
uiElement.InspectMe(x => x.pivot);

// Inspecting a complex property
this.InspectMe(x => x.ComplexProperty);

Example:

public class EnvironmentController : MonoBehaviour
{
    private RectTransform uiElement;
    private float temperature;
    private float humidity;

    // Derived property
    public float ComfortIndex => (temperature + humidity) / 2;

    void Start()
    {
        // Inspecting a nested property
        uiElement.InspectMe(x => x.pivot);

        // Inspecting a complex property
        this.InspectMe(x => x.ComfortIndex);
    }
}

Dynamic Inspection with MemberInfo

Inspect properties determined at runtime using MemberInfo. This method is beneficial for properties that aren't known at compile-time.

// Dynamic property inspection
PropertyInfo propertyInfo = typeof(MyClass).GetProperty("PropertyName");
this.InspectMe(propertyInfo);

Example:

public class DynamicInspector : MonoBehaviour
{
    [SerializeField]
    private GameObject dynamicObject;

    void Start()
    {
        PropertyInfo dynamicProperty = dynamicObject.GetType().GetProperty("PropertyName");
        dynamicObject.InspectMe(dynamicProperty);
    }
}

For further assistance, don't hesitate to reach out to our support section.