public static void CompileInk(InkFile[] inkFiles, bool immediate, Action onComplete) { #if UNITY_2019_4_OR_NEWER AssetDatabase.DisallowAutoRefresh(); #endif InkLibrary.Validate(); if (onComplete != null) { onCompleteActions.Add(onComplete); } StringBuilder filesCompiledLog = new StringBuilder("Files compiled:"); foreach (var inkFile in inkFiles) { filesCompiledLog.AppendLine().Append(inkFile.filePath); } StringBuilder outputLog = new StringBuilder(); outputLog.Append("Ink compilation started at "); outputLog.AppendLine(DateTime.Now.ToLongTimeString()); outputLog.Append(filesCompiledLog.ToString()); Debug.Log(outputLog); foreach (var inkFile in inkFiles) { CompileInkInternal(inkFile, immediate); } }
public static void Bake([NotNull] MeshAnimationAsset asset) { if (asset == null) { throw new ArgumentNullException(nameof(asset)); } var error = asset.GetValidationMessage(); if (error != null) { throw new InvalidOperationException(error); } try { AssetDatabase.DisallowAutoRefresh(); EditorUtility.DisplayProgressBar("Mesh Animator", "Baking", 0f); DestroyObject(ref asset.bakedTexture); CreateTexture(asset, out var aborted); if (!aborted) { CreateMaterial(asset); BakeAnimations(asset); } SaveAsset(asset); } finally { EditorUtility.ClearProgressBar(); AssetDatabase.AllowAutoRefresh(); } }
///--------------------------------------------------------------------- /// Called at 10 frames per second private void OnInspectorUpdate() { var startWork = false; if (startMarkUp > 0) { var progress = Math.Max(0, Math.Min(1, (EditorApplication.timeSinceStartup - startMarkUp) / startDuration)); if (EditorUtility.DisplayCancelableProgressBar("Work start in:", string.Empty, (float)progress)) { startMarkUp = -1; EditorUtility.ClearProgressBar(); } else if (progress >= 1) { startWork = true; } } if (startWork) { startMarkUp = -1; EditorUtility.ClearProgressBar(); foreach (var builder in activeCodeBuilders) { builder.RunInTestMode = runInTestMode.value; builder.Init(); builder.StartWork(); } isWorking = true; AssetDatabase.DisallowAutoRefresh(); } if (isWorking) { isWorking = false; rootVisualElement.SetEnabled(true); if (activeCodeBuilders.Count > 0) { activeCodeBuilders.RemoveAll((x) => { return(x == null); }); for (int b = 0; b < activeCodeBuilders.Count; b++) { var builder = activeCodeBuilders[b]; if (builder.IsWorking) { rootVisualElement.SetEnabled(false); builder.Update(); isWorking = true; } } } if (!isWorking) { AssetDatabase.AllowAutoRefresh(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } } }
public static async Task Execute() { AssetDatabase.DisallowAutoRefresh(); progress = 0; UpdateProgressBar(0.1f, nameof(Execute)); await DownloadSubmoduleAsync(); AssetDatabase.Refresh(); UpdateProgressBar(1 - progress, "Finish"); AssetDatabase.AllowAutoRefresh(); EditorUtility.ClearProgressBar(); }
internal void DownloadRepositoryToPathIfNeeded( string cloudRepository, string cloudOrganization, string projectPath, string unityAccessToken) { AssetDatabase.DisallowAutoRefresh(); try { BuildProgressSpeedAndRemainingTime.ProgressData progressData = new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now); ThreadPool.QueueUserWorkItem( DownloadRepository, new DownloadRepositoryParameters() { CloudOrganization = cloudOrganization, CloudRepository = cloudRepository, ProjectPath = projectPath, AccessToken = unityAccessToken }); while (!mOperationFinished) { if (mDisplayProgress) { DisplayProgress( mUpdateNotifier.GetUpdateStatus(), progressData, cloudRepository); } Thread.Sleep(150); } } finally { EditorUtility.ClearProgressBar(); AssetDatabase.AllowAutoRefresh(); RefreshAsset.UnityAssetDatabase(); if (!mOperationFailed) { AssetMenuItems.Enable(); ShowWindow.PlasticAfterDownloadingProject(); } } }
public static void CompileInk(InkFile[] inkFiles, bool immediate, Action onComplete = null) { if (inkFiles == null || inkFiles.Length == 0) { return; } #if UNITY_2019_4_OR_NEWER if (!disallowedAutoRefresh) { disallowedAutoRefresh = true; try { AssetDatabase.DisallowAutoRefresh(); } catch (Exception e) { Debug.LogWarning("Failed DisallowAutoRefresh " + e); } } #endif InkLibrary.Validate(); if (onComplete != null) { onCompleteActions.Add(onComplete); } StringBuilder filesCompiledLog = new StringBuilder("Files compiled:"); foreach (var inkFile in inkFiles) { filesCompiledLog.AppendLine().Append(inkFile.filePath); } StringBuilder outputLog = new StringBuilder(); outputLog.Append("Ink compilation started at "); outputLog.AppendLine(DateTime.Now.ToLongTimeString()); outputLog.Append(filesCompiledLog.ToString()); Debug.Log(outputLog); foreach (var inkFile in inkFiles) { CompileInkInternal(inkFile, immediate); } }
public static void BuildProject() { if (_isAnythingRunning) { return; } _isAnythingRunning = true; ClearConsoleLogs(); AssetDatabase.DisallowAutoRefresh(); Debug.Log("---->>> Starting C++ project build"); BuildOutputParser parser = new BuildOutputParser(); ProcessRunner runner = new ProcessRunner(_cppProjectPath, _cmakeCachesPath, parser); if (!Directory.Exists(runner.cmakeCachesPath)) { Directory.CreateDirectory(runner.cmakeCachesPath); } EditorUtility.DisplayProgressBar(_progressBarTitle, "Starting C++ project build", 0F); string[] arguments = { _buildTypeParameter, $"-G \"{_cmakeGenerationString}\"", $"\"{runner.cppProjectPath}\"", $"-B \"{runner.cmakeCachesPath}\"", }; runner.applicationPath = _cmakePath; runner.arguments = arguments; runner.workingDirectory = runner.cppProjectPath; runner.progressUpdateEvent = UpdateProgressBar; runner.exitEvent = DidFinishGeneratingCppProject; runner.RunProcess(); }
public static void CompileInk(params InkFile[] inkFiles) { _postAssetDataBaseRefreshActions.Clear(); AssetDatabase.DisallowAutoRefresh(); try { CompileInk(inkFiles, true, null); //use immediate=true to avoid thread access issues. } finally { AssetDatabase.AllowAutoRefresh(); } AssetDatabase.Refresh(); foreach (var action in _postAssetDataBaseRefreshActions) { action(); } _postAssetDataBaseRefreshActions.Clear(); InkLibrary.Save(); InkMetaLibrary.Save(); }
internal void DownloadRepositoryToPathIfNeeded( string cloudRepository, string cloudOrganization, string projectPath) { var allowAutoRefreshFeature = new AssetDatabase().GetType().GetMethod("DisallowAutoRefresh") != null; #if allowAutoRefreshFeature AssetDatabase.DisallowAutoRefresh(); #endif try { BuildProgressSpeedAndRemainingTime.ProgressData progressData = new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now); ThreadPool.QueueUserWorkItem( DownloadRepository, new DownloadRepositoryParameters() { CloudOrganization = cloudOrganization, CloudRepository = cloudRepository, ProjectPath = projectPath, AccessToken = CloudProjectSettings.accessToken }); while (!mOperationFinished) { if (mDisplayProgress) { DisplayProgress( mUpdateNotifier.GetUpdateStatus(), progressData, cloudRepository); } Thread.Sleep(150); } } finally { EditorUtility.ClearProgressBar(); #if allowAutoRefreshFeature AssetDatabase.AllowAutoRefresh(); #endif DisableCollabIfEnabled(projectPath); RefreshAsset.UnityAssetDatabase(); if (!mOperationFailed) { // we just download a cloud project, // so let's assume we're going to use Cloud Edition SetupUnityEditionToken.ToCloud(); ShowWindow.Plastic(); } } }
private static void GenerateForDataTypes(Type[] dataTypes) { var @namespace = $"{typeof(DataContainer).Namespace}.GeneratedClasses"; var codeFileInfos = GenerateCodeFiles(@namespace, GenerateTypeDeclarations(dataTypes)); var directory = new DirectoryInfo(Path.Combine(Application.dataPath, "Generated", "JakePerry", "ScriptableData")); directory.Create(); // Get reference to the project folder (one up from Assets). var projectDirFullName = directory.Parent.Parent.Parent.Parent.FullName; int trimCount = projectDirFullName.Length + 1; if (projectDirFullName.EndsWith("/") || projectDirFullName.EndsWith("\\")) { trimCount++; } AssetDatabase.DisallowAutoRefresh(); try { int debugCount = 0; foreach (var codeFileInfo in codeFileInfos) { var file = WriteCodeFile(codeFileInfo, directory); var fileFullName = file.FullName; Debug.Assert(fileFullName.StartsWith(projectDirFullName)); var projectRelativePath = fileFullName.Substring(trimCount).Replace('\\', '/'); AssetDatabase.ImportAsset(projectRelativePath); var monoScript = AssetDatabase.LoadAssetAtPath <MonoScript>(projectRelativePath); if (monoScript == null) { Logger.LogError($"Failed to find generated file at path {projectRelativePath}"); continue; } EditorAssetUtilities.AddLabel(monoScript, GENERATED_SCRIPT_LABEL); debugCount++; } AssetDatabase.Refresh(); if (debugCount == codeFileInfos.Length) { Logger.Log($"Successfully generated {debugCount.ToString()} code files."); } else { Logger.Log($"{debugCount.ToString()} of {codeFileInfos.Length.ToString()} files were successfully generated."); } } finally { AssetDatabase.AllowAutoRefresh(); } }