How does one use yield in C#. It behaves differently then the Javascript version of yield.
I was trying to convert this Javascript example to C#. It doesn't seem to call the corfunAlp routine. Help!
using UnityEngine;
using System.Collections;
public class fader : MonoBehaviour {
public GameObject gamobjBac;
Color thecolor;
// Use this for initialization
void Start ()
{
corfunAlp (gamobjBac, 0, 1, 1);
// Turn opaque
corfunAlp (gamobjBac, 4, 1, 0);
// Turn transparent
}
// Update is called once per frame
void Update ()
{
}
//function that fades alpha for a game object up or down with a start delay and duration of fade
public IEnumerator corfunAlp (GameObject gamobjGamObj, float floWai, float floDur, int intAlpGoa)
{
float floAlp = (1 - intAlpGoa);
intAlpGoa = ((2 * intAlpGoa) - 1);
yield return new WaitForSeconds (floWai);
while (floAlp >= 0 && floAlp <= 1)
{
thecolor = gamobjGamObj.renderer.material.GetColor ("_Color");
thecolor.a = floAlp;
gamobjGamObj.renderer.material.SetColor ("_Color", thecolor);
floAlp = floAlp + ((Time.deltaTime/floDur)*intAlpGoa);
yield return true;
}
}
}