Advertisement
Muk99

CompilingTime

Dec 18th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using UnityEditor;
  2. using UnityEngine;
  3.  
  4. [InitializeOnLoad]
  5. static class Compiling {
  6.  
  7.     private static bool isCompiling {
  8.         set { EditorPrefs.SetBool("IsCompiling", value); }
  9.         get { return EditorPrefs.GetBool("IsCompiling"); }
  10.     }
  11.     private static double lastTimeCompiling {
  12.         set { EditorPrefs.SetString("LastTimeCompiling", value.ToString()); }
  13.         get { return double.Parse(EditorPrefs.GetString("LastTimeCompiling", EditorApplication.timeSinceStartup.ToString())); }
  14.     }
  15.     private static double compiledTime {
  16.         get { return EditorApplication.timeSinceStartup - lastTimeCompiling; }
  17.     }
  18.  
  19.     static Compiling() {
  20.         EditorApplication.update += () => {
  21.             if(EditorApplication.isCompiling == isCompiling)
  22.                 return;
  23.  
  24.             if(isCompiling = EditorApplication.isCompiling)
  25.                 lastTimeCompiling = EditorApplication.timeSinceStartup;
  26.             else if(compiledTime > 0d)
  27.                 Debug.LogFormat("Compiled in {0} seconds", compiledTime.ToString("0.00"));
  28.         };
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement