|
Hello i have this script.
I want to create a GUI switch that turns this stream on and off. The web cam material is streamed on the plane. My first solution was to just disable the plane render. But that still leaves the stream open and it takes resource that can be used somewhere else. Then i edited the code so that it had a bool value on or off. If the value was false then it just skipped the while loop in my code. It worked only half way. Because my Update cam function is called on Start() it only initializes the true or false value and thats it. I turn my GUI switch off but nothing happens because the default value was already initialized in Start() So i took my Update cam function and put it into Update() method. It worked perfectly. I could switch the stream on and off but since the update was called on every frame my application nearly freezed. Since i am new to programming can anyone give me the pointers how to call that UpdateCam() function so that it only checks it once in a second. I know that there is Time.DeltaTime supposed to be in there but all this syntax thing is very new for me. Of course if you have even better solution then please tell me. Thank you for your time.
(comments are locked)
|
|
i shall answer my own question. I came up with this and it works.
using System.Collections; public class streamScreen : MonoBehaviour { #region Fields //streamScreen myComponent; // public bool cameraOnOff = true; public string url = ""; float cameraUpdate = 0.1f; bool onOff = false;
} Thank you for your time. :)
(comments are locked)
|
