Created
April 19, 2015 14:30
-
-
Save suakig/4a14add015c7bfb149e8 to your computer and use it in GitHub Desktop.
TimeDoSample.cs
This file contains hidden or 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 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