private static string GetTokenFromStorage(GameObject obj)
        {
            // Check if the mesh object
            FoundryUniqueToken tokenStore = obj.GetComponent <FoundryUniqueToken>();

            // If the token store exists on the game object
            // use that one because it's probably an object that STP created
            if (tokenStore && !System.String.IsNullOrEmpty(tokenStore.uniqueToken))
            {
                return(tokenStore.uniqueToken);
            }

            return(null);
        }
        public static void RegenerateTokenToObjectMaps()
        {
            Debug.Log("Foundry Bridge: Generating object maps");

            // Go over all items in the scenegraph and extract STP mesh instances
            Object[] allObjects = GameObject.FindObjectsOfType(typeof(MonoBehaviour));

            foreach (var obj in allObjects)
            {
                if (obj is FoundryUniqueToken)
                {
                    FoundryUniqueToken tokenStorage = obj as FoundryUniqueToken;
                    if (tokenStorage && tokenStorage.uniqueToken != "")
                    {
                        MapTokenToObject(tokenStorage.uniqueToken, tokenStorage.gameObject);
                    }
                }
            }

            // Go over all items in the project tab and extract all STP mesh prefab items
            // Construct the system path of the asset folder
            string dataPath = Application.dataPath;

            // get the system file paths of all the files in the asset folder
            string[] aFilePaths = Directory.GetFiles(dataPath, searchPattern: "*.prefab", searchOption: SearchOption.AllDirectories);

            foreach (string sFilePath in aFilePaths)
            {
                string sAssetPath = sFilePath.Substring(dataPath.Length - rootPath.Length);

                Object objAsset = AssetDatabase.LoadAssetAtPath(sAssetPath, typeof(Object));

                if (objAsset is GameObject)
                {
                    GameObject         prefab     = objAsset as GameObject;
                    FoundryUniqueToken tokenStore = prefab.GetComponent <FoundryUniqueToken>();

                    if (tokenStore && tokenStore.uniqueToken.Length > 0)
                    {
                        MapTokenToObject(tokenStore.uniqueToken, prefab);

                        // Add mesh prefabs to the list
                        var meshFilter = prefab.GetComponent <MeshFilter>();
                        if (meshFilter && meshFilter.sharedMesh)
                        {
                            MapMeshToPrefab(meshFilter.sharedMesh, prefab);
                        }

                        // Add non STP material prefabs to the list
                        var materialStore = prefab.GetComponent <FoundryMaterialStore>();
                        if (materialStore && materialStore.material)
                        {
                            MapMaterialToPrefab(materialStore.material, prefab);
                        }
                        else
                        {
                            // Add STP materials
                            Material STPMaterial = GetMaterialFromToken(tokenStore.uniqueToken);

                            if (STPMaterial)
                            {
                                MapMaterialToPrefab(STPMaterial, prefab);
                            }
                        }
                    }
                }
            }
        }