Created
August 11, 2019 23:47
-
-
Save instance-id/6c37f67bb29423d9b2a1244ddf684f5e to your computer and use it in GitHub Desktop.
Compilation Timer using Logwin.Log() asset
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 UnityEngine; | |
using UnityEditor; | |
namespace instance.id.Editor | |
{ | |
[InitializeOnLoad] | |
class CompilationTimer : EditorWindow | |
{ | |
static bool isTrackingTime; | |
static double startTime; | |
static CompilationTimer() | |
{ | |
EditorApplication.update += Update; | |
startTime = PlayerPrefs.GetFloat("CompileStartTime", 0); | |
if (startTime > 0) | |
{ | |
isTrackingTime = true; | |
} | |
} | |
static void Update() | |
{ | |
if (EditorApplication.isCompiling && !isTrackingTime) | |
{ | |
startTime = EditorApplication.timeSinceStartup; | |
PlayerPrefs.SetFloat("CompileStartTime", (float)startTime); | |
isTrackingTime = true; | |
} | |
else if (!EditorApplication.isCompiling && isTrackingTime) | |
{ | |
var finishTime = EditorApplication.timeSinceStartup; | |
isTrackingTime = false; | |
var compileTime = finishTime - startTime; | |
PlayerPrefs.DeleteKey("CompileStartTime"); | |
var timeStamp = DateTime.Now.ToString("hh:mm:ss"); | |
Logwin.Log(timeStamp, compileTime.ToString("0.000"), "_Compilation"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment