Class SceneReferenceResolver
The scene reference resolver.
Inheritance
Implements
Inherited Members
Namespace: Bayat.Core
Assembly: Bayat.Core.Runtime.dll
Syntax
[AddComponentMenu("Bayat/Core/Scene Reference Resolver")]
[DisallowMultipleComponent]
public class SceneReferenceResolver : MonoBehaviour, ISerializationCallbackReceiver
Fields
| Improve this Doc View Sourceguids
Declaration
[HideInInspector]
[SerializeField]
protected List<string> guids
Field Value
| Type | Description |
|---|---|
| System. |
guidToReference
Declaration
[SerializeField]
protected GuidToReferenceDictionary guidToReference
Field Value
| Type | Description |
|---|---|
| Guid |
invalidGameObjectTags
Declaration
[SerializeField]
protected string[] invalidGameObjectTags
Field Value
| Type | Description |
|---|---|
| System. |
referenceResolvers
Declaration
protected static Dictionary<Scene, SceneReferenceResolver> referenceResolvers
Field Value
| Type | Description |
|---|---|
| System. |
referenceToGuid
Declaration
protected ReferenceToGuidDictionary referenceToGuid
Field Value
| Type | Description |
|---|---|
| Bayat. |
sceneDependencies
Declaration
[HideInInspector]
[SerializeField]
protected List<Object> sceneDependencies
Field Value
| Type | Description |
|---|---|
| System. |
Properties
| Improve this Doc View SourceCurrent
Gets the current scene reference resolver.
Declaration
public static SceneReferenceResolver Current { get; }
Property Value
| Type | Description |
|---|---|
| Scene |
Guids
Gets the GUIDs list.
Declaration
[Obsolete("This property will be removed in future releases, use GuidToReference or ReferenceToGuid instead.", false)]
public virtual List<string> Guids { get; }
Property Value
| Type | Description |
|---|---|
| System. |
GuidToReference
Declaration
public virtual GuidToReferenceDictionary GuidToReference { get; set; }
Property Value
| Type | Description |
|---|---|
| Guid |
ReferenceResolvers
A dictionary of all the available Scene Reference Resolvers based on the Scene they are managing.
Declaration
public static Dictionary<Scene, SceneReferenceResolver> ReferenceResolvers { get; }
Property Value
| Type | Description |
|---|---|
| System. |
Remarks
Use Get
ReferenceToGuid
Declaration
public virtual ReferenceToGuidDictionary ReferenceToGuid { get; set; }
Property Value
| Type | Description |
|---|---|
| Bayat. |
SceneDependencies
Gets the scene dependencies list.
Declaration
[Obsolete("This property will be removed in future releases, use GuidToReference or ReferenceToGuid instead.", false)]
public virtual List<Object> SceneDependencies { get; }
Property Value
| Type | Description |
|---|---|
| System. |
Methods
| Improve this Doc View SourceAdd(Object)
Adds the object to the database by generating a new GUID if it is not already in the database.
Declaration
public virtual string Add(Object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
obj |
Returns
| Type | Description |
|---|---|
| System. |
Add(Object, String)
Adds the object to the database with the given GUID if it is not empty, otherwise generates a new GUID.
Declaration
public virtual void Add(Object obj, string guid)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
obj | |
| System. |
guid |
ChangeGuid(String, String)
Changes the old GUID to the new GUID in the database.
Declaration
public virtual void ChangeGuid(string oldGuid, string newGuid)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
oldGuid | |
| System. |
newGuid |
Clear()
Clears the database.
Declaration
public virtual void Clear()
Contains(String)
Checks whether the database contains the given GUID or not.
Declaration
public virtual bool Contains(string referenceID)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
referenceID |
Returns
| Type | Description |
|---|---|
| System. |
Contains(Object)
Checks whether the database contains the given object or not.
Declaration
public virtual bool Contains(Object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
obj |
Returns
| Type | Description |
|---|---|
| System. |
CreateNewInstance()
Creates a new instance of Scene
Declaration
public static GameObject CreateNewInstance()
Returns
| Type | Description |
|---|---|
| Unity |
Get(String)
Gets the object associated with the given GUID.
Declaration
public virtual Object Get(string guid)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
guid |
Returns
| Type | Description |
|---|---|
| Unity |
Get(Object)
Gets the given object reference GUID.
Declaration
public virtual string Get(Object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
obj |
Returns
| Type | Description |
|---|---|
| System. |
GetAllUnityObjects()
Gets all referenced Unity objects from all the currently available reference resolvers.
Declaration
public static List<Object> GetAllUnityObjects()
Returns
| Type | Description |
|---|---|
| System. |
Returns a List of currently referenced Unity objecs from the available reference resolvers |
Remarks
It retrieves the referenced Unity objects from the currently open scenes that have a Scene
GetAnyGuidReference(Object)
Searches through all reference resolvers and gets the referenced unityObject's GUID.
Declaration
public static string GetAnyGuidReference(Object unityObject)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
unityObject | The referenced Unity object |
Returns
| Type | Description |
|---|---|
| System. |
Returns the referenced |
GetAnyUnityObjectReference(String)
Searches through all reference resolvers and gets the Unity object by the specified guid.
Declaration
public static Object GetAnyUnityObjectReference(string guid)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
guid | The referenced Unity object GUID |
Returns
| Type | Description |
|---|---|
| Unity |
Returns the referenced Unity object if available, otherwise null |
GetReferenceResolver(Scene)
Gets the reference resolver for the specified scene.
Declaration
public static SceneReferenceResolver GetReferenceResolver(Scene scene)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
scene | The scene to look for the reference resolver |
Returns
| Type | Description |
|---|---|
| Scene |
Returns the reference resolver in the provided scene if available, otherwise null |
GetSceneGuidReference(Scene, Object)
Gets the referenced unityObject GUID from the specified scene's reference resolver if available.
Declaration
public static string GetSceneGuidReference(Scene scene, Object unityObject)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
scene | The scene to look for the reference resolver |
| Unity |
unityObject | The referenced Unity object |
Returns
| Type | Description |
|---|---|
| System. |
Returns the referenced |
GetSceneUnityObjectReference(Scene, String)
Gets the Unity object from the specified scene's reference resolver if available.
Declaration
public static Object GetSceneUnityObjectReference(Scene scene, string guid)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
scene | The scene to look for the reference resolver |
| System. |
guid | The referenced Unity object GUID |
Returns
| Type | Description |
|---|---|
| Unity |
Returns the referenced Unity object if available, otherwise null |
GetUnityObjectScene(Object)
Gets the Unity object's scene.
Declaration
public static Scene? GetUnityObjectScene(Object unityObject)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
unityObject | The Unity object |
Returns
| Type | Description |
|---|---|
| System. |
Returns the Unity object's scene if it is a GameObject or Component, otherwise null |
Remarks
First checks if the provided Unity object is a GameObject or Component, then uses the GameObject.scene property to retrieve the scene the Unity object is residing at.
HasNullValues()
Returns true if the database has null references, otherwise true.
Declaration
public virtual bool HasNullValues()
Returns
| Type | Description |
|---|---|
| System. |
OnAfterDeserialize()
Declaration
public virtual void OnAfterDeserialize()
OnBeforeSerialize()
Declaration
public virtual void OnBeforeSerialize()
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
protected virtual void OnEnable()
Remove(String)
Removes the GUID and the associated object from the database.
Declaration
public virtual void Remove(string referenceID)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
referenceID |
Remove(Object)
Removes the object and its GUID from the database.
Declaration
public virtual void Remove(Object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity |
obj |
RemoveDuplicateValues()
Removes the duplicate values.
Declaration
public virtual void RemoveDuplicateValues()
RemoveNullValues()
Removes null values and references from the database.
Declaration
public virtual void RemoveNullValues()
Reset()
Declaration
public virtual void Reset()