Class PrefabHelper
Helper for Prefabs.
public static class PrefabHelper
- Inheritance
-
PrefabHelper
- Inherited Members
Properties
PrefabToGameObject
Gets a IReadOnlyDictionary<TKey, TValue> of PrefabType and their corresponding UnityEngine.GameObject.
public static IReadOnlyDictionary<PrefabType, GameObject> PrefabToGameObject { get; }
Property Value
- IReadOnlyDictionary<PrefabType, GameObject>
PrefabToGameObjectAndComponent
Gets a IReadOnlyDictionary<TKey, TValue> of PrefabType and their corresponding UnityEngine.GameObject.
public static IReadOnlyDictionary<PrefabType, (GameObject, Component)> PrefabToGameObjectAndComponent { get; }
Property Value
- IReadOnlyDictionary<PrefabType, (GameObject, Component)>
Methods
GetPrefab(PrefabType)
Gets the UnityEngine.GameObject of the specified PrefabType.
public static GameObject GetPrefab(PrefabType prefabType)
Parameters
prefabTypePrefabTypeThe PrefabType.
Returns
- GameObject
Returns the UnityEngine.GameObject.
GetPrefabAttribute(PrefabType)
Gets the PrefabAttribute from a PrefabType.
public static PrefabAttribute GetPrefabAttribute(this PrefabType prefabType)
Parameters
prefabTypePrefabTypeThe PrefabType.
Returns
- PrefabAttribute
The corresponding PrefabAttribute.
GetPrefab<T>(PrefabType)
Gets a UnityEngine.Component from the UnityEngine.GameObject of the specified PrefabType.
public static T GetPrefab<T>(PrefabType prefabType) where T : Component
Parameters
prefabTypePrefabTypeThe PrefabType.
Returns
- T
Returns the UnityEngine.Component.
Type Parameters
TThe UnityEngine.Component type.
Spawn(PrefabType, Vector3, Quaternion?)
Spawns the UnityEngine.GameObject of the specified PrefabType.
public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null)
Parameters
prefabTypePrefabTypeThe PrefabType.
positionVector3The UnityEngine.Vector3 position where the UnityEngine.GameObject will spawn.
rotationQuaternion?The UnityEngine.Quaternion rotation of the UnityEngine.GameObject.
Returns
- GameObject
Returns the UnityEngine.GameObject instantied.
Spawn<T>(PrefabType, Vector3, Quaternion?)
Spawns the UnityEngine.GameObject of the specified PrefabType.
public static T Spawn<T>(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null) where T : Component
Parameters
prefabTypePrefabTypeThe PrefabType.
positionVector3The UnityEngine.Vector3 position where the UnityEngine.GameObject will spawn.
rotationQuaternion?The UnityEngine.Quaternion rotation of the UnityEngine.GameObject.
Returns
- T
Returns the UnityEngine.Component of the UnityEngine.GameObject.
Type Parameters
TThe UnityEngine.Component type.
TryGetPrefab(PrefabType, out GameObject)
Tries to get the UnityEngine.GameObject of the specified PrefabType.
public static bool TryGetPrefab(PrefabType prefabType, out GameObject gameObject)
Parameters
prefabTypePrefabTypeThe PrefabType.
gameObjectGameObjectThe UnityEngine.GameObject of the .
Returns
- bool
Returns true if the UnityEngine.GameObject was found.