Skip to content

Instantly share code, notes, and snippets.

@kaiware007
Created July 5, 2016 07:42
Show Gist options
  • Save kaiware007/508f63d0907429f2c9b6cf18389e96e9 to your computer and use it in GitHub Desktop.
Save kaiware007/508f63d0907429f2c9b6cf18389e96e9 to your computer and use it in GitHub Desktop.
エディットモード中に実行せずに一定時間おきに更新処理を行う方法 ref: http://qiita.com/kaiware007/items/871392e318abafe8b531
#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