(Sorry for my english)
I have a scene with 3 mesches. Each mesh has this script:
using UnityEngine;
using System.Collections;
public class Button : MonoBehaviour {
public Shader shader1;
public Shader shader2;
public Object levelToLoad;
void Start()
{
shader1 = Shader.Find("Diffuse");
shader2 = Shader.Find("Self-Illumin/Diffuse");
renderer.material.shader = shader1; //to include the shader Self-Illumin/Diffuse in the build
}
void Update()
{
}
void OnMouseOver()
{
renderer.material.shader = shader2;
}
void OnMouseExit()
{
renderer.material.shader = shader1;
}
void OnMouseDown()
{
Application.LoadLevel(levelToLoad.name);
}
}
I assign the script to each mesh and the scene to load to each script, but when i build and run the progect and i click on a mesh instead of load the assigned scene appear an error on the development console.
This is the error: NullReferenceException: Object reference not set to an istance of an object
How can i fix this error?