Пример #1
0
    private void Start()
    {
        if (!CHECK_GUIDS_INTEGRITY)
        {
            return;
        }

        // Test that the GUID's are unique, very important when developing the API in a future, this method will be deleted
        if (sceneGUIDs == null)
        {
            sceneGUIDs = FindObjectsOfType <S_Guid>();
            for (int i = 0; i < sceneGUIDs.Length; i++)
            {
                S_Guid guidToTest = sceneGUIDs[i];
                for (int j = 0; j < sceneGUIDs.Length; j++)
                {
                    // Don't test against the same GUID
                    if (i != j)
                    {
                        if (guidToTest.GUID.Equals(sceneGUIDs[j].GUID))
                        {
                            Debug.LogError(
                                string.Format("SpatialStoriesAPI: Error Gameobject {0} and {1} contains the same guid {2}",
                                              guidToTest.name, sceneGUIDs[j].name, guidToTest.GUID));
                        }
                    }
                }
            }
        }
    }
Пример #2
0
        /// <summary>
        /// Finds an already created object by GUID.
        /// </summary>
        /// <param name="_guid">The guid of the object</param>
        /// <returns></returns>
        public static GameObject GetObjectOfTypeWithGUID(string _guid)
        {
            S_Guid[] guids = GameObject.FindObjectsOfType <S_Guid>();

            for (int i = 0; i < guids.Length; i++)
            {
                S_Guid guid = guids[i];
                if (guid.GUID.Equals(_guid))
                {
                    return(guid.gameObject);
                }
            }
            return(null);
        }