static void Export_Assets_Queue() { if (currentBuildTarget.HasValue && nextBuildSubTarget.HasValue) { currentBuildSubTarget = nextBuildSubTarget; nextBuildSubTarget = null; if (currentBuildTarget.Equals(BuildTarget.Android)) { if (buildAllSubtarget && androidSubtargetDictionary.ContainsKey(bundleVersionList [currentBuildSubTarget.Value] + 1)) { nextBuildSubTarget = androidSubtargetDictionary [bundleVersionList [currentBuildSubTarget.Value] + 1]; } JSFTPlatform.SwitchPlatform(JSFTShared.CacheTargetForBuildTarget(currentBuildTarget).Value, JSFTShared.CacheSubtargetForAndroidBuildSubtarget(currentBuildSubTarget).Value); if (EditorUserBuildSettings.activeBuildTarget.Equals(currentBuildTarget) && EditorUserBuildSettings.androidBuildSubtarget.Equals(currentBuildSubTarget)) { ExportSD_Asset(); } } else { JSFTPlatform.SwitchPlatform(JSFTShared.CacheTargetForBuildTarget(currentBuildTarget).Value); if (EditorUserBuildSettings.activeBuildTarget.Equals(currentBuildTarget)) { ExportSD_Asset(); } } } }
private static void CompressAllCacheOperation(bool background, Shared.CacheTarget? currentCacheTarget, Shared.CacheSubtarget? currentCacheSubtarget) { // Process all targets & subtargets for (int i = 0; i < (int) Shared.CacheTarget.Count; i++) { var target = (Shared.CacheTarget) i; if (target == Shared.CacheTarget.Android) { for (int j = (int) Shared.CacheSubtarget.Android_First + 1; j < (int) Shared.CacheSubtarget.Android_Last; j++) { var subtarget = (Shared.CacheSubtarget) j; if (GetCacheStatus(target, subtarget) && !GetCacheCompression(target, subtarget) && !(Preferences.EnableHardLinks && target == currentCacheTarget && subtarget == currentCacheSubtarget)) CompressCache(target, subtarget, background); } } #if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 else if (target == Shared.CacheTarget.BlackBerry) { for (int j = (int) Shared.CacheSubtarget.BlackBerry_First + 1; j < (int) Shared.CacheSubtarget.BlackBerry_Last; j++) { var subtarget = (Shared.CacheSubtarget) j; if (GetCacheStatus(target, subtarget) && !GetCacheCompression(target, subtarget) && !(Preferences.EnableHardLinks && target == currentCacheTarget && subtarget == currentCacheSubtarget)) CompressCache(target, subtarget, background); } } #endif else { if (GetCacheStatus(target, null) && !GetCacheCompression(target, null) && !(Preferences.EnableHardLinks && target == currentCacheTarget && null == currentCacheSubtarget)) CompressCache(target, null, background); } } }
public static void DecompressCache(Shared.CacheTarget? target, Shared.CacheSubtarget? subtarget, bool silent = false) { if (!target.HasValue) return; string metadataCacheFolder = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata"; CompressionManager.PerformDecompression(metadataCacheFolder, silent); }
public static void ClearCache(Shared.CacheTarget? target, Shared.CacheSubtarget? subtarget) { if (!target.HasValue) return; string metadataCacheFolder = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata"; string metadataCacheLz4File = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata.jcf.lz4"; string metadataCacheTimestampsFile = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "timestamps"; if (Directory.Exists(metadataCacheFolder)) Shared.DeleteDirectory(metadataCacheFolder); if (File.Exists(metadataCacheLz4File)) File.Delete(metadataCacheLz4File); if (File.Exists(metadataCacheTimestampsFile)) File.Delete(metadataCacheTimestampsFile); }
public static long GetCacheSize(Shared.CacheTarget? target, Shared.CacheSubtarget? subtarget) { if (!target.HasValue) return -1; string metadataCacheFolder = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata"; string metadataCacheLz4File = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata.jcf.lz4"; return File.Exists(metadataCacheLz4File) ? (new FileInfo(metadataCacheLz4File)).Length : CalculateFolderSize(metadataCacheFolder); }
public static DateTime GetCacheDate(Shared.CacheTarget? target, Shared.CacheSubtarget? subtarget) { if (!target.HasValue) return DateTime.Now; string metadataCacheFolder = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata"; string metadataCacheLz4File = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata.jcf.lz4"; return File.Exists(metadataCacheLz4File) ? File.GetLastWriteTime(metadataCacheLz4File) : Directory.GetLastWriteTime(metadataCacheFolder); }
public static bool GetCacheCompression(Shared.CacheTarget? target, Shared.CacheSubtarget? subtarget) { if (!target.HasValue) return false; string metadataCacheLz4File = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata.jcf.lz4"; return File.Exists(metadataCacheLz4File); }
public static bool GetCacheStatus(Shared.CacheTarget? target, Shared.CacheSubtarget? subtarget) { if (!target.HasValue) return false; string metadataCacheFolder = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata"; string metadataCacheLz4File = Preferences.CachePath + Shared.CacheTargetPrefixes[(int) target.Value] + (subtarget.HasValue ? Shared.CacheSubtargetPrefixes[(int) subtarget.Value] : "") + "metadata.jcf.lz4"; return Directory.Exists(metadataCacheFolder) || File.Exists(metadataCacheLz4File); }
public static void SwitchPlatform(Shared.CacheTarget? cacheTarget, Shared.CacheSubtarget? cacheSubtarget, bool apiSwitch) { if (cacheTarget == CurrentCacheTarget && cacheSubtarget == CurrentCacheSubtarget) return; BuildTarget? newBuildTarget = Shared.BuildTargetForCacheTarget(cacheTarget); if (CurrentCacheTarget == null || newBuildTarget == null || cacheTarget == null || (newBuildTarget == EditorUserBuildSettings.activeBuildTarget && CurrentCacheSubtarget == cacheSubtarget)) return; // Make sure we have a cache subtarget for platforms that require theme if (cacheTarget == Shared.CacheTarget.Android && cacheSubtarget == null) { cacheSubtarget = Shared.CacheSubtarget.Android_GENERIC; } #if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 else if (cacheTarget == Shared.CacheTarget.BlackBerry && cacheSubtarget == null) { cacheSubtarget = Shared.CacheSubtarget.BlackBerry_GENERIC; } #endif if (apiSwitch == false) { int option = EditorUtility.DisplayDialogComplex( "Do you want to save the changes you made in the scene " + (string.IsNullOrEmpty(EditorApplication.currentScene) ? "Untitled" : EditorApplication.currentScene) + "?", "Platform switching requires closing the current scene to process cache. Your changes will be lost if you don't save them.", "Save", "Don't Save", "Cancel"); switch (option) { case 0: EditorApplication.SaveScene(); break; case 1: break; case 2: return; default: return; } } LogUtility.LogImmediate("-------------------------------------------------------"); LogUtility.LogImmediate("Switching from {0} ({1}) to {2} ({3})", CurrentCacheTarget.ToString(), CurrentCacheSubtarget.HasValue ? CurrentCacheSubtarget.Value.ToString() : "Base", cacheTarget, cacheSubtarget.HasValue ? cacheSubtarget.Value.ToString() : "Base"); EditorUtility.DisplayProgressBar("Hold on", "Persisting assets and import settings to disk...", 0.5f); PlatformRefreshCurrentScene = EditorApplication.currentScene; EditorApplication.NewScene(); _newCacheTarget = cacheTarget; _newCacheSubtarget = cacheSubtarget; SwitchOperationInProgress = true; SwitchOperationIsApi = apiSwitch; PlatformRefreshInProgress = true; ShouldSerializeAssets = true; }
public static bool SwitchPlatform(Shared.CacheTarget target, Shared.CacheSubtarget? subtarget = null) { if (CacheManager.SwitchOperationInProgress) { Debug.LogWarning("You can only perform one switch operation at a time."); return false; } // Check we're in editor and not running if (Application.isEditor == false || EditorApplication.isPlayingOrWillChangePlaymode) { Debug.LogWarning("Platform switch can only happen in editor and not during play mode."); return false; } // Check external version control for Unity < 4.3 #if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if (EditorSettings.externalVersionControl == ExternalVersionControl.Disabled) { Debug.LogWarning ("External version control (.meta files) needs to be enabled in your editor settings."); return false; } #endif // Check that we're trying to switch to a new target if (target == CacheManager.CurrentCacheTarget && subtarget == CacheManager.CurrentCacheSubtarget) { Debug.LogWarning("Switch operation not triggered because target platform is already active."); return false; } // Refresh Asset Database AssetDatabase.Refresh(); WantsSwitchOperation = true; WantedCacheTarget = target; WantedCacheSubtarget = subtarget; return true; }