예제 #1
0
    private static void CreateAssetBundlesConfigDataBase(List <AssetBundlesConfig.Rule> list)
    {
        string fileName = typeof(AssetBundlesConfig).Name;
        string path     = System.IO.Path.Combine(BUNDLE_CONFIG_DATA_FOLDER, fileName + ".asset");

        if (File.Exists(path))
        {
            AssetBundlesConfig database = (AssetBundlesConfig)AssetDatabase.LoadAssetAtPath(path, typeof(AssetBundlesConfig));

            if (null == database)
            {
                return;
            }
            database._rules = list;

            EditorUtility.SetDirty(database);
        }
        else
        {
            AssetBundlesConfig database = ScriptableObject.CreateInstance <AssetBundlesConfig>();

            database._rules = list;
            AssetDatabase.CreateAsset(database, path);
        }
    }
예제 #2
0
    private void SetupBundles()
    {
        _bundlesConfig          = AssetDatabase.LoadMainAssetAtPath(_params.AssetBundleConfigPath) as AssetBundlesConfig;
        _bundleLevelDataBase    = AssetDatabase.LoadMainAssetAtPath(_params.BundleLevelDataBasePath) as BundleLevelDataBase;
        _bundlesDatabaseBuilder = new AssetBundlesDatabaseBuilder(AssetBundlesDatabaseTempPath);

        if ((_params.Options & BuildOptions.AcceptExternalModificationsToPlayer) == 0)
        {
            FileUtil.DeleteFileOrDirectory(_params.BundlesLocation);
        }
    }
 private void LoadConfig(string[] bundleNames)
 {
     try
     {
         string configJson = File.ReadAllText(Path.Combine(buildFolder, ConfigFileName));
         config = JsonUtility.FromJson <AssetBundlesConfig>(configJson);
     }
     catch (Exception)
     {
         config = new AssetBundlesConfig
         {
             AssetBundleInfos = new AssetBundleInfo[bundleNames.Length]
         };
         for (int assetBundleIndex = 0; assetBundleIndex < bundleNames.Length; assetBundleIndex++)
         {
             config.AssetBundleInfos[assetBundleIndex] = new AssetBundleInfo
             {
                 Name = bundleNames[assetBundleIndex]
             };
         }
     }
 }
        private void GenerateAssetBundlesConfig()
        {
            if (config == null)
            {
                config = new AssetBundlesConfig
                {
                    AssetBundleInfos = new AssetBundleInfo[assetBundleNames.Length]
                };
            }

            for (int assetBundleIndex = 0; assetBundleIndex < assetBundleNames.Length; assetBundleIndex++)
            {
                string assetBundleName = assetBundleNames[assetBundleIndex];

                AssetBundleInfo info = new AssetBundleInfo {
                    Name = assetBundleName
                };

                TextField baseUriInput = rootVisualElement.Query <TextField>("baseUri");
                string    uri          = baseUriInput != null ? baseUriInput.value : "";
                if (uri.EndsWith("/") == false)
                {
                    uri += "/";
                }
                uri     += targetPlatform.ToString();
                uri     += "/" + assetBundleName;
                info.Uri = uri;

                TextField versionInput = rootVisualElement.Query <TextField>(assetBundleName + "Version");
                uint.TryParse(versionInput.value, out info.Version);

                config.AssetBundleInfos[assetBundleIndex] = info;
            }

            File.WriteAllText(Path.Combine(buildFolder, "assetBundlesConfig.json"), JsonUtility.ToJson(config));
        }