using UnityEngine;
using System.Collections;
public struct UpdateYield {
public float time;
public float time1;
public object Compare2;
public bool UWaitForSecondsF (object Compare1, float YieldTime){
Debug.Log("in the function");
if (Compare2 != Compare1){
Debug.Log("Changing compare 2");
Compare2 = Compare1;
time = Time.time;
return false;
}
time1 = Time.time;
// if it's X seconds same return true
if (((time1 - time) > YieldTime) && Compare1 == Compare2){
return true;
}
return false;
}
}
// testing
public UpdateYield asdf;
void Update () {
bool bah = asdf.UWaitForSecondsF(5, 3);
if (bah){Debug.Log("yield time works");}
}
when I change both objects in to floats the code works
object Compare2; -- > float Compare2
how should I change my code that I could put anything inside and that it won’t think all the time it’s not same IF it hasn’t been changed?
I know I could use coroutine but there are 1-3 ocasions I cannot do that in my code
and would like less thinking and more doing