pub struct MonoBehaviour {
pub m_Enabled: u8,
pub m_GameObject: PPtr,
pub m_Name: String,
pub m_Script: PPtr,
}Expand description
MonoBehaviour is a class of the Unity engine since version 3.4.0. Exert from Unity’s scripting documentation: MonoBehaviour is a base class that many Unity scripts derive from. MonoBehaviour offers life cycle functions that make it easier to develop with Unity.MonoBehaviours always exist as a Component of a GameObject, and can be instantiated with GameObject.AddComponent. Objects that need to exist independently of a GameObject should derive from ScriptableObject instead.A MonoBehaviour can be deleted with Object.Destroy or Object.DestroyImmediate. When the parent GameObject is destroyed all components are automatically deleted, including MonoBehaviours.After the underlying component is destroyed, the C# object for the MonoBehaviour remains in memory until garbage is collected. A MonoBehaviour in this state acts as if it is null. For example, it returns true for a “obj == null” check.
However, this class doesn’t support the null-conditional operator (?.) and the null-coalescing operator (??).When a MonoBehaviour is serialized, the value of C# fields are included according to Unity’s Serialization rules. See Script Serialization for details.
The serialized data also includes internal properties, such as the reference to the MonoScript that tracks the implementation class for the object.For code samples, see the individual MonoBehaviour methods.Note: There is a checkbox for enabling or disabling MonoBehaviour in the Unity Editor. It disables
functions when unticked. If none of these functions are present in the script, the Unity Editor does not
display the checkbox. The functions are:Start() Update() FixedUpdate() LateUpdate() OnGUI() OnDisable() OnEnable()See Also: The Deactivating GameObjects page in the manual.
Fields§
§m_Enabled: u8Enabled Behaviours are Updated, disabled Behaviours are not.
m_GameObject: PPtrThe game object this component is attached to. A component is always attached to a game object.
PPtr<GameObject>: (3.4.0 - 2022.3.2f1)
m_Name: StringThe name of the object.
m_Script: PPtrPPtr<MonoScript>: (3.4.0 - 2022.3.2f1)