So I currently have a video saved in my projects folder. I have this video play onto a plane using the following code:
function OnMouseDown ()
{
renderer.material.mainTexture.Play();//NOTE TWO
}
This works fine and will play on click.
I want to have a texture on the plane before it’s clicked, texture could look like a “play” button. The code I have for this is:
var url = "http://icons.iconarchive.com/icons/deleket/button/256/Button-Play-icon.png";
function Start()
{
var www : WWW = new WWW (url);
yield www;
renderer.material.mainTexture = www.texture;//NOTE ONE
}
On start the texture I want to have on the plane is there and that’s fine, but if I click the plane I get an error.
I know that my error is happening because of the two lines I’ve commented.
The line marked “NOTE ONE” is changing what ‘mainTexture’ refrences, and it now references a 2d image. So when it gets to “NOTE TWO” the code is trying to ‘Play()’ a 2d image which can’t work.
My question, how do I reference the image at “NOTE ONE” so that it isn’t changing mainTexture, but will still show the image as its texture?