Beispiel #1
0
        public Timer(int targetFPS, TickCallback callback)
        {
            TargetFPS       = targetFPS;
            FrameTime       = 1.0 / TargetFPS;
            m_Callback      = callback;
            m_AverageSmooth = 1 - FrameTime;

            Reset();
        }
    public static IEnumerator run(Config config, TickCallback onTick = null)
    {
        double startTime   = EditorApplication.timeSinceStartup;
        double elapsedTime = 0;

        while (elapsedTime < (config.duration ?? double.PositiveInfinity))
        {
            elapsedTime = EditorApplication.timeSinceStartup - startTime;

            var input = new Input();
            input.elapsedTime   = (float)elapsedTime;
            input.remainingTime = config.duration != null ? (float)elapsedTime - config.duration ?? 0 : float.NaN;

            var output = onTick?.Invoke(input);
            if ((output?.stop ?? false))
            {
                break;
            }

            yield return(null);
        }
    }
Beispiel #3
0
 public TickTimer(TickCallback tickCallback, int tickTime, int totalTime)
 {
     this.tickTime     = tickTime;
     this.totalTime    = totalTime;
     this.tickCallback = tickCallback;
 }
Beispiel #4
0
 static extern void GLUT_RegisterTick(TickCallback tickCallback);
Beispiel #5
0
 /// <summary>
 /// Sets the TickCallback method to be invoked each update
 /// </summary>
 /// <param name="tickCallback">Provides the deltaTime and unscaledDeltaTime for each frame</param>
 public void SetTickCallback(TickCallback tickCallback)
 {
     _tickCallback = tickCallback;
 }