Created
July 5, 2016 07:42
-
-
Save kaiware007/508f63d0907429f2c9b6cf18389e96e9 to your computer and use it in GitHub Desktop.
エディットモード中に実行せずに一定時間おきに更新処理を行う方法 ref: http://qiita.com/kaiware007/items/871392e318abafe8b531
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
#if UNITY_EDITOR | |
static double waitTime = 0; | |
void OnEnable() | |
{ | |
waitTime = EditorApplication.timeSinceStartup; | |
EditorApplication.update += EditorUpdate; | |
} | |
void OnDisable() | |
{ | |
EditorApplication.update -= EditorUpdate; | |
} | |
// 更新処理 | |
void EditorUpdate() | |
{ | |
foreach (var go in Selection .gameObjects) | |
{ | |
// 選択中のオブジェクトのみ更新 | |
if (go == this.gameObject) | |
{ | |
// 1/60秒に1回更新 | |
if (( EditorApplication.timeSinceStartup - waitTime) >= 0.01666f ) | |
{ | |
// 君だけの更新処理を書こう! | |
UpdateFunc(); | |
SceneView.RepaintAll(); // シーンビュー更新 | |
waitTime = EditorApplication.timeSinceStartup; | |
break; | |
} | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment