IUnityObject

Root interface mirroring UnityEngine.Object. Defines the identity and equality contract common to all Unity objects — instance ID, name, hide flags, and standard object methods. This is the base of both the IComponent chain (scene objects) and IScriptableObject (asset objects).

Definition

Namespace: Paragon Assembly: Paragon.dll

public interface IUnityObject

Remarks

IUnityObject mirrors the public API surface of UnityEngine.Object that is relevant for identity and serialization control. Any class inheriting from UnityEngine.Object (which includes MonoBehaviour, ScriptableObject, Component, etc.) inherently satisfies this interface — no explicit IUnityObject declaration is needed on the class.

The interface serves as the common root for two inheritance branches:

Properties

name

The name of the object. Maps to UnityEngine.Object.name.

string name { get; set; }

hideFlags

Bit mask controlling object visibility and persistence in the editor and at runtime. Maps to UnityEngine.Object.hideFlags.

Methods

GetInstanceID

Returns the unique instance ID assigned by Unity. Stable for the lifetime of the object.

Returns: Unique integer identifier.

GetHashCode

Returns a hash code for the object. Maps to UnityEngine.Object.GetHashCode().

Equals

Determines whether the specified object is equal to this instance. Maps to UnityEngine.Object.Equals().

Parameter
Type
Description

other

object

The object to compare

Returns: true if the objects are equal (by Unity's reference equality rules).

ToString

Returns a string representation of the object. Maps to UnityEngine.Object.ToString().

Implementation Requirements

circle-info

You do not need to implement this interface explicitly. Any class deriving from UnityEngine.Object already has all these members. The interface exists to enable interface-based programming against Unity types.

For non-Unity objects that implement IUnityObject (e.g., FactorableObject via its GetInstanceID() override), you MUST:

  1. Provide a unique GetInstanceID() value (see FactorableObject's thread-safe counter pattern)

  2. Implement meaningful Equals() and GetHashCode() for collection usage

See Also

Last updated