UxrComponent Class
Base class for components in UltimateXR. Has functionality to access the global lists of UltimateXR components, cache Unity components, access initial transform values and some other common utilities. To enumerate all components use the static properties AllComponents and EnabledComponents.
Inheritance Hierarchy
System.Object
Object
Component
Behaviour
MonoBehaviour
UltimateXR.Core.Components.UxrComponent
More…
Namespace: UltimateXR.Core.Components
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public abstract class UxrComponent : MonoBehaviour
The UxrComponent type exposes the following members.
Constructors
Name | Description | |
---|---|---|
UxrComponent |
Properties
Name | Description | |
---|---|---|
AllComponents | Gets all the components, enabled or not, in all open scenes. | |
EnabledComponents | Gets all components that are enabled, in all open scenes. | |
InitialEulerAngles | Gets the eulerAngles value at the moment of Awake() | |
InitialLocalEulerAngles | Gets the localEulerAngles value at the moment of Awake() | |
InitialLocalPosition | Gets the localPosition value at the moment of Awake() | |
InitialLocalRotation | Gets the localRotation value at the moment of Awake() | |
InitialLocalScale | Gets the localScale value at the moment of Awake() | |
InitialLocalToWorldMatrix | Gets the localToWorldMatrix value at the moment of Awake() | |
InitialLossyScale | Gets the lossyScale value at the moment of Awake() | |
InitialParent | Gets the parent value at the moment of Awake() | |
InitialPosition | Gets the position value at the moment of Awake() | |
InitialRelativeMatrix | Gets the transformation matrix relative to the parent transform at the moment of Awake() | |
InitialRotation | Gets the rotation value at the moment of Awake() | |
IsApplicationQuitting | Gets or sets whether the application is quitting. An application is known to be quitting when OnApplicationQuit() was called. | |
UniqueId | Gets the unique Id of the component. |
Methods
Name | Description | |
---|---|---|
Awake | Stores all initial transform values that can be useful for child classes. | |
DestroyAllComponents | Destroys all components. | |
DestroyAllGameObjects | Destroys all gameObjects the components belong to. | |
GetCachedComponent<T> | Returns a Unity Component cached by type given that there is only one in the GameObject. If there is more than one, it will return the first that GetComponent``1() gets. This method is mainly used to avoid boilerplate code in property getters that return internally cached components. | |
OnApplicationQuit | Sets the IsApplicationQuitting value to indicate that the application is quitting. | |
OnDestroy | Unity OnDestroy() handling. | |
OnDisable | Unity OnDisable() handling. | |
OnEnable | Unity OnEnable() handling. | |
OnValidate | Unity OnValidate() handling. | |
RecomputeInitialTransformData | Caches the data of the GameObject’s Transform component. This is called on Awake() but can be called by the user at any point of the program to re-compute the values again using the current state. This can be useful when an object is re-parented and the data using the new parenting is more meaningful. | |
Reset | Unity Reset() handling. | |
Start | Unity Start() handling. | |
TryGetComponentById | Tries to get a component by its unique id. | |
TrySetUniqueId | Changes the object’s unique Id if it doesn’t exist. |
Events
Name | Description | |
---|---|---|
GlobalDisabled | Called when a component was disabled. | |
GlobalEnabled | Called when a component was enabled. | |
GlobalIdChanged | Called when a component changed its unique id by using TrySetUniqueId(String). Parameters are oldId, newId. | |
GlobalIdChanging | Called when a component is about to change its unique id by using TrySetUniqueId(String). Parameters are oldId, newId. | |
GlobalRegistered | Called when a component was registered. | |
GlobalRegistering | Called before registering a component. | |
GlobalUnregistered | Called when a component was unregistered. | |
GlobalUnregistering | Called before unregistering a component. |
Extension Methods
Name | Description | |
---|---|---|
CheckSetEnabled | Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.) | |
GetOrAddComponent<T> | Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.) | |
GetPathUnderScene | Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.) | |
GetSceneUid | Gets an unique identifier string for the given component. (Defined by ComponentExt.) | |
GetUniqueScenePath | Gets an unique path in the scene for the given component. It will include scene name, sibling and component indices to make it unique. (Defined by ComponentExt.) | |
LoopCoroutine | Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.) | |
SafeGetComponentInParent<T> | Gets the Component of a given type in the GameObject or any of its parents. It also works on prefabs, where regular GetComponentInParent(Type, Boolean) will not work: https://issuetracker.unity3d.com/issues/getcomponentinparent-is-returning-null-when-the-gameobject-is-a-prefab (Defined by ComponentExt.) | |
ShowInInspector(Boolean) | Overloaded. Controls whether to show the current object in the inspector. (Defined by ObjectExt.) | |
ShowInInspector(Boolean, Boolean) | Overloaded. Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.) | |
ThrowIfNull | Throws an exception if the object is null. (Defined by ObjectExt.) |
Remarks
Make sure to override the Unity methods used, and call the base implementation in the body. Components get registered through their Awake() call. This means that components get registered the first time they are enabled. Disabled objects that have been enabled at some point are enumerated, but objects that have never been enabled don’t get enumerated, which means that they will not appear in AllComponents.
See Also
Reference
UltimateXR.Core.Components Namespace