Exemplo n.º 1
0
        private void Setup()
        {
            if (string.IsNullOrEmpty(Prefs.externalResourcesPath) || string.IsNullOrEmpty(Prefs.assetManageConfigGUID))
            {
                return;
            }

            var externalResourcesPath = Prefs.externalResourcesPath;
            var assetManageConfigPath = AssetDatabase.GUIDToAssetPath(Prefs.assetManageConfigGUID);
            var assetManageConfig     = AssetDatabase.LoadMainAssetAtPath(assetManageConfigPath) as AssetManageConfig;

            AssetManageConfig.OnReloadAsObservable().Subscribe(_ => Setup()).AddTo(Disposable);

            assetManageManager = new AssetManageManager();
            assetManageManager.Initialize(externalResourcesPath, assetManageConfig);

            if (!string.IsNullOrEmpty(Prefs.selectionAssetGUID))
            {
                var assetPath = AssetDatabase.GUIDToAssetPath(Prefs.selectionAssetGUID);
                selectionAssetObject = AssetDatabase.LoadMainAssetAtPath(assetPath);

                UpdateViewInfo(selectionAssetObject);
            }

            initialized = true;

            Repaint();
        }
Exemplo n.º 2
0
        private static void ApplyAssetBundleName(AssetManageManager assetManageManager, AssetInfoManifest manifest)
        {
            var assetInfos = manifest.GetAssetInfos().ToArray();

            var count = assetInfos.Length;

            AssetDatabase.StartAssetEditing();

            for (var i = 0; i < count; i++)
            {
                var assetInfo = assetInfos[i];

                EditorUtility.DisplayProgressBar("ApplyAssetBundleName", assetInfo.ResourcePath, (float)i / count);

                var assetPath = PathUtility.Combine(assetManageManager.ExternalResourcesPath, assetInfo.ResourcePath);

                if (assetInfo.IsAssetBundle)
                {
                    assetManageManager.SetAssetBundleName(assetPath, assetInfo.AssetBundle.AssetBundleName);
                }
            }

            AssetDatabase.StopAssetEditing();

            EditorUtility.ClearProgressBar();
        }
Exemplo n.º 3
0
        //----- method -----

        public AssetCollectInfo(AssetManageManager assetManageManager, string assetPath, AssetInfo assetInfo, ManageInfo manageInfo, IgnoreType?ignoreType)
        {
            this.assetManageManager = assetManageManager;

            AssetPath  = assetPath;
            AssetInfo  = assetInfo;
            ManageInfo = manageInfo;
            Ignore     = ignoreType;
        }
        //----- params -----

        //----- field -----

        //----- property -----

        //----- method -----

        public static void Generate(string externalResourcesPath, AssetManageConfig config)
        {
            var assetManageManager = new AssetManageManager();

            assetManageManager.Initialize(externalResourcesPath, config);

            var manifest = GenerateManifest(assetManageManager);

            ApplyAssetBundleName(assetManageManager, manifest);

            UnityEditorUtility.SaveAsset(manifest);

            AssetDatabase.RemoveUnusedAssetBundleNames();
            AssetDatabase.Refresh();
        }
Exemplo n.º 5
0
        private void Initialize(string externalResourcesPath, AssetManageConfig assetManageConfig)
        {
            // コンパイルが始まったら閉じる.
            CompileNotification.OnCompileStartAsObservable()
            .Subscribe(_ => Close())
            .AddTo(Disposable);

            assetManageConfig.Optimisation();

            assetManageModel = new AssetManageModel();
            assetManageModel.Initialize();

            assetManageManager = new AssetManageManager();
            assetManageManager.Initialize(externalResourcesPath, assetManageConfig);

            manageAssetView = new ManageAssetView();
            manageAssetView.Initialize(assetManageModel, assetManageManager);

            assetManageModel.OnRequestRepaintAsObservable().Subscribe(_ => Repaint()).AddTo(Disposable);
        }
Exemplo n.º 6
0
        //----- property -----

        //----- method -----

        public void Initialize(AssetManageModel assetManageModel, AssetManageManager assetManageManager)
        {
            if (initialized)
            {
                return;
            }

            this.assetManageModel   = assetManageModel;
            this.assetManageManager = assetManageManager;

            assetManageModel.OnDragAndDropAsObservable().Subscribe(x => OnDragAndDrop(x)).AddTo(Disposable);

            assetManageManager.CollectInfo();

            selectionGroupInfo = null;

            BuildManageInfoViews();

            initialized = true;
        }
Exemplo n.º 7
0
        private static AssetInfoManifest GenerateManifest(AssetManageManager assetManageManager)
        {
            // アセット情報を収集.
            assetManageManager.CollectInfo();

            var allAssetInfos = assetManageManager.GetAllAssetInfos().ToArray();

            // アセット情報を更新.
            var manifestPath = GetManifestPath(assetManageManager.ExternalResourcesPath);
            var manifest     = ScriptableObjectGenerator.Generate <AssetInfoManifest>(manifestPath);

            Reflection.SetPrivateField(manifest, "assetInfos", allAssetInfos);

            UnityEditorUtility.SaveAsset(manifest);

            // アセットバンドル名設定.
            var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(manifest));

            importer.assetBundleName = AssetInfoManifest.AssetBundleName;
            importer.SaveAndReimport();

            return(manifest);
        }