Hey everyone. What I am trying to do is change a texture on a plane that I am using for my front end.
In the scene I have: A plane with the texture, A menu script that has all my GUI info a camera and a light.
On the plane there is a material with a .mov file and there is a piece of the code on the plane that lets you use an animated texture.
The code:
function Start () {
renderer.material.mainTexture.Play ();
}
Now what I am looking to do is, when the player clicks a button in the Main Menu Script, it will swap this texture with a different animated texture. I have tried a lot of different stuff but where I am at now is.
var mainBG : Texture;
var gamepadBG : Texture;
function Awake() {
timeScale = Time.timeScale;
director = GameObject.Find(“Director”).GetComponent(“Director”);
volumeSlider = director.volume;
}
function HowToPlayScreenJoyControls() { // This will be the first screen for the how to play part
if (GUILayout.Button(“>>>”, GUI.skin.label)) {
screen = “HowToPlayKey”;
}
GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // infos that will be relavent eventually
GUILayout.Label(“How To Play: Game Pad”);
GUILayout.FlexibleSpace(); GUILayout.EndHorizontal();
var bg : GameObject = GameObject.Find(“Background”).GetComponent(“Background”);
bg.renderer.material.mainTexture = gamepadBG;
// With this last line I am getting a NullReferenceException: Object reference not set to an instance of an object.
}
There is obviously more code than what I have put but these are the only pieces that are interacting with the texture I am trying to change. I am still fairly new to scripting so my apologies if I am missing something obvious.
Also would it be better to put the first bit of code into the Main Menu script and just put it all on the background instead of having it on a separate game object?
Thanks for any help.