Skip to content

Instantly share code, notes, and snippets.

@suakig
Created April 19, 2015 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suakig/4a14add015c7bfb149e8 to your computer and use it in GitHub Desktop.
Save suakig/4a14add015c7bfb149e8 to your computer and use it in GitHub Desktop.
TimeDoSample.cs
using UnityEngine;
using System.Collections;
public class TimeDoSample : MonoBehaviour {
public bool stopTime;
float time = 0.1f;
TimeDo update;
TimeDo updateAnyTimeDo;
TimeDo fixedUpdate;
void Start ()
{
update = new TimeDo (time, false);
updateAnyTimeDo = new TimeDo (time, false);
fixedUpdate = new TimeDo (time, false);
Invoke ("Run", time);
}
void Update ()
{
if (stopTime) {
Time.timeScale = 0;
} else {
Time.timeScale = 1;
}
if (update.Update (TimeDo.Type.Loop, TimeDo.When.AnyTimeDo)) {
Debug.Log ("update.Update (TimeDo.Type.Loop, TimeDo.When.AnyTimeDo)");
}
if (updateAnyTimeDo.Update (TimeDo.Type.Loop, TimeDo.When.Nomal)) {
Debug.Log ("updateAnyTimeDo.Update (TimeDo.Type.Loop, TimeDo.When.Nomal)");
}
}
void FixedUpdate(){
if (fixedUpdate.Update (TimeDo.Type.Loop, TimeDo.When.Nomal)) {
Debug.Log ("fixedUpdate.Update (TimeDo.Type.Loop, TimeDo.When.Nomal)");
}
}
void Run()
{
Debug.Log ("Run()");
Invoke ("Run", time);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment