Esempio n. 1
0
        private static void SetMetadata(string path, string name)
        {
            switch (pb_FileUtility.GetPathType(path))
            {
            case PathType.File:
            {
                UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(path);

                GameObject go = obj as GameObject;

                // [05.07.2019] https://www.reddit.com/r/Unity3D/comments/a8u4c1/obsolete_functions_i_have_no_idea_how_to_replace/
                if (go != null && PrefabUtility.GetPrefabAssetType(go) == PrefabAssetType.Regular)
                {
                    pb_MetaDataComponent metadata = go.GetComponent <pb_MetaDataComponent>();

                    if (!metadata)
                    {
                        metadata = go.AddComponent <pb_MetaDataComponent>();
                    }

                    metadata.SetAssetBundleData(name, path);
                }

                break;
            }

            case PathType.Directory:
            {
                foreach (string subdir in Directory.GetDirectories(path))
                {
                    SetMetadata(subdir, name);
                }

                foreach (string asset in Directory.GetFiles(path))
                {
                    SetMetadata(asset, name);
                }

                break;
            }

            default:
                break;
            }
        }
Esempio n. 2
0
        private static void SetMetadata(string path, string name)
        {
            switch (pb_FileUtility.GetPathType(path))
            {
            case PathType.File:
            {
                UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(path);

                GameObject go = obj as GameObject;

                if (go != null && PrefabUtility.GetPrefabType(go) == PrefabType.Prefab)
                {
                    pb_MetaDataComponent metadata = go.GetComponent <pb_MetaDataComponent>();

                    if (!metadata)
                    {
                        metadata = go.AddComponent <pb_MetaDataComponent>();
                    }

                    metadata.SetAssetBundleData(name, path);
                }

                break;
            }

            case PathType.Directory:
            {
                foreach (string subdir in Directory.GetDirectories(path))
                {
                    SetMetadata(subdir, name);
                }

                foreach (string asset in Directory.GetFiles(path))
                {
                    SetMetadata(asset, name);
                }

                break;
            }

            default:
                break;
            }
        }