Question by
SHADOWxWOLF · Feb 06, 2017 at 05:29 AM ·
reflectiondelayupdate functionprobes
Delay a Reflection update probe in script
Im still pretty new to the coding side of unity and im working on a lightswitch were it will turn off and on the light and then update the reflection prob of the room to match the new lighting but when i flip the switch it updates the probe before the light can even turn off. and the question is how would i delay the update of it. here is the code so far.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class lightswitch : MonoBehaviour {
public Light Light;
public GameObject goLightSwitch;
public ReflectionProbe Probe;
int renderID = -1;
private bool _switchOn;
void OnMouseDown()
{
if(_switchOn)
{
_switchOn = false;
Light.enabled = false;
renderID = Probe.RenderProbe ();
}
else if (!_switchOn)
{
_switchOn = true;
Light.enabled = true;
renderID = Probe.RenderProbe ();
}
}
}
Comment
Answer by KillerNads · Feb 23, 2017 at 05:06 AM
@SHADOWxWOLF please can you tell me if you solved this as i also am stuck with this!!
thanks
I actually managed to solve this by the following, it works but im not sure if its the best way of doing it!
Invoke("UpdateProbe", timeDelay); //timeDelay is a float in seconds
void UpdateProbe ()
{
probe.RenderProbe ();
}