private static Object GenerateScriptableObject(Type type, string assetPath) { assetPath = Path.ChangeExtension(assetPath, AssetFileExtension); var instance = AssetDatabase.LoadAssetAtPath(assetPath, type); if (instance == null) { var projectPath = UnityPathUtility.ConvertProjectPath(assetPath); var path = PathUtility.Combine(Application.dataPath, projectPath); if (!File.Exists(path)) { instance = CreateInstance(type); AssetDatabase.CreateAsset(instance, assetPath); AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } return(instance); }
private static string PrepareExportDirectory(IApplicationBuilder applicationBuilder, bool batchMode) { // 出力先. var directory = string.Empty; directory = GetExportDirectory(applicationBuilder, batchMode); if (string.IsNullOrEmpty(directory)) { return(null); } var platformName = PlatformUtility.GetPlatformName(); var exportFolderName = applicationBuilder.GetExportFolderName(); directory = PathUtility.Combine(new string[] { directory, platformName, exportFolderName }); // 既存の成果物を破棄. FileUtil.DeleteFileOrDirectory(directory); // 出力先作成. if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } return(directory); }
private void BuildAssetInfo(string externalResourcesPath) { var manifestPath = PathUtility.Combine(externalResourcesPath, AssetInfoManifest.ManifestFileName); var assetInfoManifest = AssetDatabase.LoadAssetAtPath <AssetInfoManifest>(manifestPath); var allAssetInfos = assetInfoManifest.GetAssetInfos().ToArray(); var list = new List <AssetInfo>(); foreach (var assetInfo in allAssetInfos) { var assetPath = PathUtility.Combine(externalResourcesPath, assetInfo.ResourcesPath); var dependencies = AssetDatabase.GetDependencies(assetPath); dependencies = dependencies.Where(x => x != assetPath).ToArray(); var invalidDependants = dependencies .Where(x => !x.StartsWith(externalResourcesPath)) .Where(x => !IgnoreExtensions.Contains(Path.GetExtension(x))) .ToArray(); if (invalidDependants.IsEmpty()) { continue; } list.Add(new AssetInfo(assetPath, invalidDependants)); } assetInfos = list.ToArray(); }
public static void CreateDirectories(string basePath) { Directory.CreateDirectory(basePath); Directory.CreateDirectory(PathUtility.Combine(basePath, RELATIVE_PREVIEW_PATH)); Directory.CreateDirectory(PathUtility.Combine(basePath, RELATIVE_NOTIFICATIONS_PATH)); Directory.CreateDirectory(PathUtility.Combine(basePath, RELATIVE_SETTINGS_PATH)); }
//------ fields ------ //------ property ------ //------ methods ------ public static bool Generate() { var directory = string.Empty; var assetPath = string.Empty; var selectionObject = Selection.activeObject; if (selectionObject != null) { var path = AssetDatabase.GetAssetPath(selectionObject); directory = AssetDatabase.IsValidFolder(path) ? path : Path.GetDirectoryName(path); var assetName = Path.GetFileName(DefaultAssetPath); assetPath = PathUtility.Combine(directory, assetName); } else { assetPath = DefaultAssetPath; } var instance = GenerateScriptableObject(typeof(ScriptableObject), assetPath); UnityEditorUtility.SelectAsset(instance); return(instance); }
/// <summary> /// CriAssetをアセットバンドルの出力先にコピー. /// </summary> /// <param name="exportPath"></param> /// <param name="externalResourcesPath"></param> private static void CopyCriManagedFiles(string exportPath, string externalResourcesPath) { var assetPaths = AssetDatabase.FindAssets(string.Empty, new string[] { externalResourcesPath }) .Select(x => AssetDatabase.GUIDToAssetPath(x)) .ToArray(); foreach (var assetPath in assetPaths) { var path = assetPath.Replace(externalResourcesPath, string.Empty); var source = PathUtility.Combine(UnityPathUtility.GetProjectFolderPath(), assetPath); var dest = PathUtility.Combine(new string[] { exportPath, CriAssetDefinition.CriAssetFolder, path }); if (PathUtility.GetFilePathType(source) == PathUtility.FilePathType.File) { var extension = Path.GetExtension(source); if (CriAssetDefinition.AssetAllExtensions.Contains(extension)) { var directory = Path.GetDirectoryName(dest); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } File.Copy(source, dest, true); } } } }
private AssetBundleCreateRequest CreateBundleLoadRequest() { Logger.LogInfo("Bundle load request does not exist, create it from file: {0}", _path); foreach (var basePath in _searchPaths) { var path = PathUtility.Combine(basePath, _path); // Avoid throwing error messages. if (PathUtility.IsFileInPersistentDataPath(path) && !File.Exists(path)) { Logger.LogInfo("AssetBundle cannot load at path: {0}, searching next ... ", path); continue; } Profiler.BeginSample("BundleLoaderAsync:CreateBuiltinBundleLoadRequest - AssetBundle.LoadFromFileAsync"); var bundleLoadRequest = LoadAssetBundleAsync(path); Profiler.EndSample(); if (bundleLoadRequest != null) { return(bundleLoadRequest); } Logger.LogInfo("AssetBundle cannot load at path: {0}, searching next ... ", path); } throw new BundleLoadFailedException(string.Format("Cannot load assetbundle: {0}", this)); }
public void SetCriAssetFileInfo(string exportPath, IProgress <Tuple <string, float> > progress = null) { for (var i = 0; i < assetInfos.Length; i++) { var assetInfo = assetInfos[i]; if (assetInfo.IsAssetBundle) { continue; } var extension = Path.GetExtension(assetInfo.FileName); var filePath = string.Empty; if (CriAssetDefinition.AssetAllExtensions.Any(x => x == extension)) { filePath = PathUtility.Combine(new string[] { exportPath, assetInfo.FileName }); } assetInfo.SetFileInfo(filePath); progress.Report(Tuple.Create(assetInfo.ResourcePath, (float)i / assetInfos.Length)); } BuildCache(true); }
/// <summary> 情報書き込み後のAssetInfoManifestをビルド </summary> public void BuildAssetInfoManifest() { var projectFolders = ProjectFolders.Instance; if (projectFolders == null) { return; } var externalResourcesPath = projectFolders.ExternalResourcesPath; var assetBundlePath = GetAssetBundleOutputPath(); var manifestPath = PathUtility.Combine(externalResourcesPath, AssetInfoManifest.ManifestFileName); // 必ず更新するのでパッケージファイルを削除. var manifestFullPath = PathUtility.Combine(assetBundlePath, AssetInfoManifest.ManifestFileName); var manifestFilePackage = Path.ChangeExtension(manifestFullPath, AssetBundleManager.PackageExtension); if (File.Exists(manifestFilePackage)) { File.Delete(manifestFilePackage); } var buildMap = new AssetBundleBuild[] { new AssetBundleBuild() { assetNames = new string[] { manifestPath }, assetBundleName = AssetInfoManifest.AssetBundleName, }, }; bundlePipeline.Build(assetBundlePath, buildMap); }
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(); }
public void ApplyAllAssetBundleName(bool force = false) { AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); var allAssetInfos = GetAllAssetInfos().ToArray(); using (new AssetEditingScope()) { var count = allAssetInfos.Length; for (var i = 0; i < count; i++) { var assetInfo = allAssetInfos[i]; if (!assetInfo.IsAssetBundle) { continue; } var assetPath = PathUtility.Combine(externalResourcesPath, assetInfo.ResourcePath); var importer = AssetImporter.GetAtPath(assetPath); if (ApplyAssetBundleName(importer, assetInfo.AssetBundle.AssetBundleName, force)) { EditorUtility.DisplayProgressBar("Apply AssetBundleName", assetInfo.FileName, (float)i / count); } } EditorUtility.ClearProgressBar(); } AssetDatabase.RemoveUnusedAssetBundleNames(); AssetDatabase.Refresh(); }
//----- method ----- public static void Generate(string scriptPath) { var enums = new StringBuilder(); var layers = InternalEditorUtility.layers.Select(c => new { var = ScriptGenerateUtility.RemoveInvalidChars(c), val = LayerMask.NameToLayer(c) }).ToArray(); for (var i = 0; i < layers.Length; ++i) { enums.Append("\t\t").AppendFormat(@"{0} = {1},", layers[i].var, layers[i].val); // 最終行は改行しない. if (i < layers.Length - 1) { enums.AppendLine(); } } var script = ScriptTemplate; script = Regex.Replace(script, "#ENUMS#", enums.ToString()); script = script.FixLineEnd(); var folderPath = PathUtility.Combine(scriptPath, @"Constants"); ScriptGenerateUtility.GenerateScript(folderPath, @"Layers.cs", script); }
/// <summary> /// Adds the specified resource to the cache /// </summary> /// <param name="applicationName">The application that owns the resource</param> /// <param name="resource"><see cref="Resource"/> to cache</param> /// <returns>The ID of the added resource</returns> public static string Add(string applicationName, Resource resource) { string id = null; if (IsCacheConfigured && !String.IsNullOrEmpty(applicationName) && resource != null) { string path = GetApplicationCacheDirectoryName(applicationName); DirectoryInfo appDirectory = CreateAppCacheDirectory(path); // do this every time, in case the underlying filesystem has changed if (!cache.ContainsKey(appDirectory.FullName)) { cache.Add(appDirectory.FullName, new Dictionary <string, string>()); } id = PathUtility.GetSafeFileName(resource.GetKey()); Dictionary <string, string> appCache = cache[appDirectory.FullName]; if (appCache.ContainsKey(id)) { appCache.Remove(id); } string filename = String.Format(@"{0}{1}", id, EXTENSION); string filepath = PathUtility.Combine(appDirectory.FullName, filename); System.Drawing.Image image = (Image)resource; using (image) { if (image != null) { image.Save(filepath); } } if (!appCache.ContainsKey(id)) { appCache.Add(id, filepath); } } return(id); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(string scriptPath) { var fields = new StringBuilder(); var all = new StringBuilder(); var tags = InternalEditorUtility.tags; for (var i = 0; i < tags.Length; ++i) { fields.Append("\t\t").AppendFormat("public const string {0} = \"{0}\";", tags[i]); all.Append("\t\t\t").AppendFormat("{0},", tags[i]); // 最終行は改行しない. if (i < tags.Length - 1) { fields.AppendLine(); all.AppendLine(); } } var script = ScriptTemplate; script = Regex.Replace(script, "#FIELDS#", fields.ToString()); script = Regex.Replace(script, "#ALL#", all.ToString()); script = script.FixLineEnd(); var folderPath = PathUtility.Combine(scriptPath, @"Constants"); ScriptGenerateUtility.GenerateScript(folderPath, @"Tags.cs", script); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(string scriptPath, string rootFolderPath) { var infos = LoadUsmInfo(rootFolderPath); var enums = new StringBuilder(); var contents = new StringBuilder(); for (var i = 0; i < infos.Length; i++) { var info = infos[i]; var assetPath = info.Usm.Replace(rootFolderPath + PathUtility.PathSeparator, string.Empty); var enumName = ScriptGenerateUtility.GetCSharpName(PathUtility.GetPathWithoutExtension(assetPath), false); enums.Append("\t\t\t").AppendFormat(EnumTemplate, enumName); contents.Append("\t\t\t").AppendFormat(ContentsTemplate, enumName, info.UsmPath); if (i < infos.Length - 1) { enums.AppendLine(); contents.AppendLine(); } } var script = ScriptTemplate; script = Regex.Replace(script, "@ENUMS", enums.ToString()); script = Regex.Replace(script, "@CONTENTS", contents.ToString()); var folderPath = PathUtility.Combine(scriptPath, @"Constants"); ScriptGenerateUtility.GenerateScript(folderPath, @"Movies.cs", script); }
/// <summary> 情報書き込み後のAssetInfoManifestをビルド </summary> public static void BuildAssetInfoManifest(string externalResourcesPath) { var assetBundlePath = GetAssetBundleOutputPath(); var manifestPath = PathUtility.Combine(externalResourcesPath, AssetInfoManifest.ManifestFileName); var buildMap = new AssetBundleBuild[] { new AssetBundleBuild() { assetNames = new string[] { manifestPath }, assetBundleName = AssetInfoManifest.AssetBundleName, }, }; // 必ず更新するのでパッケージファイルを削除. var manifestFullPath = PathUtility.Combine(assetBundlePath, AssetInfoManifest.ManifestFileName); var manifestFilePackage = Path.ChangeExtension(manifestFullPath, AssetBundleManager.PackageExtension); if (File.Exists(manifestFilePackage)) { File.Delete(manifestFilePackage); } var targetPlatform = EditorUserBuildSettings.activeBuildTarget; BuildPipeline.BuildAssetBundles(assetBundlePath, buildMap, BuildAssetBundleOptions.ChunkBasedCompression, targetPlatform); }
private static void Import(string workspace, Settings settings) { var title = "Select Index File"; var filter = string.Format("Index File (*{0})|*{0}", Constants.IndexFileExtension); var indexFilePath = OpenSelectFileDialog(workspace, title, filter); if (string.IsNullOrEmpty(indexFilePath)) { Exit(0); return; } if (IsEditExcelFileLocked(indexFilePath, settings)) { return; } var indexData = DataLoader.LoadSheetIndex(indexFilePath, settings); var directory = Path.GetDirectoryName(indexFilePath); var fileName = Path.GetFileNameWithoutExtension(indexFilePath); var folderPath = PathUtility.Combine(directory, fileName); var sheetData = DataLoader.LoadAllSheetData(folderPath, settings); EditExcelBuilder.Build(indexFilePath, indexData, sheetData, settings); }
public static void Generate(string scriptPath) { var internalEditorUtilityType = typeof(InternalEditorUtility); var sortingLayerNamesProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic); var sortingLayerNames = (string[])sortingLayerNamesProperty.GetValue(null, new object[0]); var sortingLayerUniqueIDsProperty = internalEditorUtilityType.GetProperty("sortingLayerUniqueIDs", BindingFlags.Static | BindingFlags.NonPublic); var sortingLayerUniqueIDs = (int[])sortingLayerUniqueIDsProperty.GetValue(null, new object[0]); var enums = new StringBuilder(); for (var i = 0; i < sortingLayerNames.Length; ++i) { enums.Append("\t\t").AppendFormat("{0} = {1},", sortingLayerNames[i], sortingLayerUniqueIDs[i]); // 最終行は改行しない. if (i < sortingLayerNames.Length - 1) { enums.AppendLine(); } } var script = ScriptTemplate; script = Regex.Replace(script, "#ENUMS#", enums.ToString()); script = script.FixLineEnd(); var folderPath = PathUtility.Combine(scriptPath, @"Constants"); ScriptGenerateUtility.GenerateScript(folderPath, @"SortingLayer.cs", script); }
private static Texture2D[] LoadIconTextures(string folderPath, IEnumerable <string> iconNames) { var iconTextures = new List <Texture2D>(); foreach (var iconName in iconNames) { var assetPath = PathUtility.Combine(folderPath, iconName); var texture = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)) as Texture2D; if (texture != null) { iconTextures.Add(texture); } else { using (new DisableStackTraceScope()) { Debug.LogErrorFormat("Icon texture not found. \n{0}\n", assetPath); } } } return(iconTextures.ToArray()); }
public override void OnBegin() { assetManageManager = null; assetInfoManifest = null; changeAssetInfo = false; var projectFolders = ProjectFolders.Instance; var assetManageConfig = AssetManageConfig.Instance; if (projectFolders != null && assetManageConfig != null) { assetManageManager = AssetManageManager.Instance; externalResourcesPath = projectFolders.ExternalResourcesPath; assetManageManager.Initialize(externalResourcesPath, assetManageConfig); var manifestPath = PathUtility.Combine(externalResourcesPath, AssetInfoManifest.ManifestFileName); assetInfoManifest = AssetDatabase.LoadAssetAtPath <AssetInfoManifest>(manifestPath); if (assetInfoManifest != null) { assetInfos = Reflection.GetPrivateField <AssetInfoManifest, AssetInfo[]>(assetInfoManifest, "assetInfos"); } } }
protected void CreateCache(byte[] bytes, string source, long updateAt, long expireAt) { // ファイル出力. var fileName = GetFileName(source); var filePath = PathUtility.Combine(FileDirectory, fileName); bytes = bytes.Encrypt(cryptoKey); using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { fileStream.Write(bytes, 0, bytes.Length); } // キャッシュ情報更新. LoadCacheContents(); cacheContents[source] = new CacheFileData(source, updateAt, expireAt); var cacheData = new CacheData() { files = cacheContents.Values.ToArray(), }; cacheData.Save(); }
public string BuildUrl(string assetBundlePath) { var platformName = UnityPathUtility.GetPlatformName(); var assetFolder = AssetBundlesFolder; return(PathUtility.Combine(new string[] { remoteUrl, platformName, assetFolder, assetBundlePath }) + PackageExtension); }
private static bool UpdateCriAssets( string criExportDir, string rootFolderName, string streamingAssetFolderName, string externalResourcesFolderName, string[] assetExtensions) { var criExportDirInternal = PathUtility.Combine(criExportDir, streamingAssetFolderName); var criExportDirExternal = PathUtility.Combine(criExportDir, externalResourcesFolderName); // アセット置き場のUnity上でのパス生成. var assetDirInternal = PathUtility.Combine(new string[] { UnityPathUtility.AssetsFolder, streamingAssetFolderName, rootFolderName }); var assetDirExternal = PathUtility.Combine(new string[] { UnityPathUtility.AssetsFolder, externalResourcesFolderName, rootFolderName }); AssetDatabase.StartAssetEditing(); // InternalResources. var upedateScript = ImportCriAsset(criExportDirInternal, assetDirInternal, assetExtensions); DeleteCriAsset(criExportDirInternal, assetDirInternal); // ExternalResources. ImportCriAsset(criExportDirExternal, assetDirExternal, assetExtensions); DeleteCriAsset(criExportDirExternal, assetDirExternal); AssetDatabase.StopAssetEditing(); return(upedateScript); }
/// <summary> パッケージファイルの名前を変更し出力先にコピー. </summary> private static async Task ExportPackage(string exportPath, string assetBundleFilePath, AssetInfo assetInfo) { // パッケージファイルパス. var packageFilePath = Path.ChangeExtension(assetBundleFilePath, AssetBundleManager.PackageExtension); if (!File.Exists(packageFilePath)) { return; } // パッケージファイル名. var packageFileName = Path.ChangeExtension(assetInfo.FileName, AssetBundleManager.PackageExtension); // ファイルの出力先. var packageExportPath = PathUtility.Combine(exportPath, packageFileName); // ディレクトリ作成. var directory = Path.GetDirectoryName(packageExportPath); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // ファイルコピー. using (var sourceStream = File.Open(packageFilePath, FileMode.Open)) { using (var destinationStream = File.Create(packageExportPath)) { await sourceStream.CopyToAsync(destinationStream); } } }
public static T Generate <T>(string assetPath = null, bool log = true) where T : ScriptableObject { assetPath = Path.ChangeExtension(string.IsNullOrEmpty(assetPath) ? DefaultAssetPath : assetPath, AssetFileExtension); var instance = AssetDatabase.LoadAssetAtPath <T>(assetPath); if (instance == null) { var projectPath = UnityPathUtility.ConvertProjectPath(assetPath); var path = PathUtility.Combine(Application.dataPath, projectPath); if (!File.Exists(path)) { AssetDatabase.CreateAsset(CreateInstance <T>(), assetPath); AssetDatabase.SaveAssets(); instance = AssetDatabase.LoadAssetAtPath <T>(assetPath); if (log) { Debug.Log(string.Format("Generate: {0}", assetPath)); } } } return(instance); }
//----- field ----- //----- property ----- //----- method ----- public static bool CheckCryptoFile(string assetBundlePath, string aesKey, string aesIv) { var changed = true; var packageCryptoFilePath = PathUtility.Combine(assetBundlePath, CryptoFileName); var packageCrypto = new PackageCrypto { cryptoKey = aesKey, cryptoIv = aesIv, }; var text = string.Empty; if (File.Exists(packageCryptoFilePath)) { try { text = File.ReadAllText(packageCryptoFilePath); var prev = JsonConvert.DeserializeObject <PackageCrypto>(text); if (prev.cryptoKey == packageCrypto.cryptoKey && prev.cryptoIv == packageCrypto.cryptoIv) { changed = false; } } catch { /* Ignore Exception */ } } return(changed); }
private static string GetExportDirectory(IApplicationBuilder applicationBuilder, bool batchMode) { var exportDir = string.Empty; // dataPathはAssetsフォルダ. var directory = Path.GetDirectoryName(Application.dataPath); if (!batchMode) { exportDir = string.IsNullOrEmpty(Prefs.exportDir) ? directory : Prefs.exportDir; var dir = Path.GetDirectoryName(exportDir); var name = Path.GetFileName(exportDir); directory = EditorUtility.SaveFolderPanel("Select OutputPath", dir, name); if (!string.IsNullOrEmpty(directory)) { Prefs.exportDir = directory; } else { return(null); } } return(PathUtility.Combine(directory, "Build")); }
/// <summary> /// Create <see cref="JsonSettingAdapter"/> for the specified special path. /// </summary> /// <param name="specialFolder">Special path on operating system.</param> /// <param name="vendorName">Unique string which identifies vendor (i.e. "Rotorz").</param> /// <param name="applicationName">Unique string which identifies vendor /// application (i.e. "unity3d-tile-system").</param> /// <param name="relativePath">Relative path of configuration file (i.e. "Settings.json"). /// This path can include additional sub directories.</param> /// <returns> /// The new <see cref="JsonSettingAdapter"/> instance. /// </returns> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="vendorName"/>, <paramref name="applicationName"/> or /// <paramref name="relativePath"/> has a value of <c>null</c>. /// </exception> /// <exception cref="System.ArgumentException"> /// Thrown if <paramref name="vendorName"/>, <paramref name="applicationName"/> or /// <paramref name="relativePath"/> is just an empty string. /// </exception> /// <seealso cref="FromPath(string)"/> /// <seealso cref="FromApplicationDataPath(string, string, string)"/> /// <seealso cref="FromApplicationDataPath(string, string)"/> private static JsonSettingAdapter FromSpecialPath(Environment.SpecialFolder specialFolder, string vendorName, string applicationName, string relativePath) { if (vendorName == null) { throw new ArgumentNullException("vendorName"); } if (applicationName == null) { throw new ArgumentNullException("applicationName"); } if (relativePath == null) { throw new ArgumentNullException("relativePath"); } if (vendorName == "") { throw new ArgumentException("vendorName"); } if (applicationName == "") { throw new ArgumentException("applicationName"); } if (relativePath == "") { throw new ArgumentException("relativePath"); } return(FromPath(PathUtility.Combine( Environment.GetFolderPath(specialFolder), vendorName, applicationName, relativePath ))); }
protected static bool LoadAssetBundleInternal(string assetBundleName, int dlcType, bool isLoadingAssetBundleManifest = false) { LoadedAssetBundle bundle = null; if (loadedAssetBundleDic.TryGetValue(assetBundleName, out bundle) && bundle != null) { bundle.referencedCount++; return(true); } if (downloadingWWWDic.ContainsKey(assetBundleName)) { return(true); } if (isLoadingAssetBundleManifest) { if (!File.Exists(PathUtility.Combine(false, AssetBundlePathUtility.GetCacheAssetpath(false), assetBundleName))) { isInitialized = true; return(false); } } string dlcUrl = PathUtility.Combine(false, AssetBundlePathUtility.GetCacheAssetpath(true), assetBundleName); WWW download = new WWW(dlcUrl); downloadingWWWDic.Add(assetBundleName, download); return(false); }
public void Init() { var dbpath = PathUtility.Combine(AppContext.Instance.ConfigLoader.Root, "storage"); if (!File.Exists(dbpath)) { System.Data.SQLite.SQLiteConnection.CreateFile(dbpath); } var scsb = new SQLiteConnectionStringBuilder(); scsb.DataSource = dbpath; _connectString = scsb.ToString(); var connection = new SQLiteConnection(_connectString); connection.Open(); //check inited; var tableExists = (long)connection.CreateCommand("select COUNT(*) from sqlite_master where type='table' and tbl_name='Version'", false).ExecuteScalar() > 0; var version = !tableExists ? new Version("0.0.0.0") : new Version((connection.CreateCommand("select [Version] from version where key='sys'", false).ExecuteScalar() ?? "0.0.0.0").ToString()); //check version if (version.Major == 0) { var sqls = new[] { @" CREATE TABLE [PreviewInfo] ( [Stype] INT NOT NULL, [Hash] NVARCHAR(128) NOT NULL, [PreviewSource] NVARCHAR(50), [PreviewType] INT NOT NULL, [WebUrl] VARCHAR(500), [ImageUrl] VARCHAR(500), [Description] NVARCHAR(1024), [LastUsed] DATETIME NOT NULL DEFAULT (datetime('now')), [HitCount] INT NOT NULL DEFAULT 1, CONSTRAINT [] PRIMARY KEY ([Stype], [Hash], [PreviewSource]) ON CONFLICT REPLACE);" , @" CREATE TABLE [Illegal] ( [SType] INT NOT NULL, [Hash] VARCHAR(128) NOT NULL, [State] INT NOT NULL, [ReportCount] INT NOT NULL, [UpdateTime] DATETIME NOT NULL, CONSTRAINT [] PRIMARY KEY ([SType], [Hash]) ON CONFLICT REPLACE);" , @" CREATE TABLE [Version] ( [Key] NVARCHAR(50) NOT NULL, [Version] NVARCHAR(50), CONSTRAINT [] PRIMARY KEY ([Key]) ON CONFLICT REPLACE);" , @" INSERT INTO Version ([Key], [Version]) VALUES ('sys','1.0.0.0')" }; Array.ForEach(sqls, s => connection.CreateCommand(s, false).ExecuteNonQuery()); version = new Version("1.0.0.0"); } connection.Close(); }