I can play my video on a texture with this javascript code like in the manual but my whole project is in c# and i cant figure out how to write tis in c#.
stared myself to death
does anyone has a solution?
thx
function Update () {
if (Input.GetButtonDown ("Jump")) {
if (renderer.material.mainTexture.isPlaying) {
renderer.material.mainTexture.Pause();
} else {
renderer.material.mainTexture.Play();
}
}
}
public class test : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
renderer.material.mainTexture.Play();
}
}
I tryed this before. I attashed it to my videotexture.
this gives me always an error :
Assets/Scripts/Movie/test.cs(13,47): error CS0117: UnityEngine.Texture' does not contain a definition for Play’
so just made this in js.
fixed it by placing the js function in standard assets and call it in my c#.
But i don’t like this way of working.
ainTexture is not needfully a movie texture, you need to cast.
JS simplifies this kind of stuff as it does that all behind the scenes but this also makes it significantly harder to solve problems where you are forced to do it yourself as you never needed to think about it.
JS is (by default) not strict about the typing, it doesn’t need to know the type of a variable, and will find the member fields and methods through reflection - but this comes at a significant performance cost.