Created
March 15, 2018 19:25
-
-
Save andykorth/13b9b314c4d82e949ce26a6e66e15f39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public static class EditorApplicationCompilationUtil { | |
static EditorApplicationCompilationUtil() { | |
EditorApplication.update += EditorApplicationCompilationUtil.OnEditorUpdate; | |
} | |
private static bool StoredCompilingState { | |
get { return EditorPrefs.GetBool("EditorApplicationCompilationUtil::StoredCompilingState"); } | |
set { EditorPrefs.SetBool("EditorApplicationCompilationUtil::StoredCompilingState", value); } | |
} | |
private static void OnEditorUpdate() { | |
if (EditorApplication.isCompiling && EditorApplicationCompilationUtil.StoredCompilingState == false) { | |
EditorApplicationCompilationUtil.StoredCompilingState = true; | |
EditorPrefs.SetString("compileTimeStart", "" + (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond)); | |
} | |
if (!EditorApplication.isCompiling && EditorApplicationCompilationUtil.StoredCompilingState == true) { | |
EditorApplicationCompilationUtil.StoredCompilingState = false; | |
AssetDatabase.SaveAssets(); | |
long startCompile = long.Parse(EditorPrefs.GetString("compileTimeStart", "0")); | |
Debug.Log("Compile time: " + (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - startCompile) + " ms."); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment