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>
Methods
GetPrefab(PrefabType)
Gets the UnityEngine.GameObject of the specified PrefabType.
public static GameObject GetPrefab(PrefabType prefabType)
Parameters
prefabType
PrefabTypeThe PrefabType.
Returns
- GameObject
Returns the UnityEngine.GameObject.
GetPrefabAttribute(PrefabType)
Gets the PrefabAttribute from a PrefabType.
public static PrefabAttribute GetPrefabAttribute(this PrefabType prefabType)
Parameters
prefabType
PrefabTypeThe 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
prefabType
PrefabTypeThe PrefabType.
Returns
- T
Returns the UnityEngine.Component.
Type Parameters
T
The 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
prefabType
PrefabTypeThe PrefabType.
position
Vector3The UnityEngine.Vector3 position where the UnityEngine.GameObject will spawn.
rotation
Quaternion?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
prefabType
PrefabTypeThe PrefabType.
position
Vector3The UnityEngine.Vector3 position where the UnityEngine.GameObject will spawn.
rotation
Quaternion?The UnityEngine.Quaternion rotation of the UnityEngine.GameObject.
Returns
- T
Returns the UnityEngine.Component of the UnityEngine.GameObject.
Type Parameters
T
The 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
prefabType
PrefabTypeThe PrefabType.
gameObject
GameObjectThe UnityEngine.GameObject of the .
Returns
- bool
Returns true if the UnityEngine.GameObject was found.