Main.cs
public class Main : MonoBehaviour {
public int a = new int();
// Use this for initialization
void Start () {
a = 0;
}
void Update () {
a++;
if(a>20)
{ a = 0; }
}
}
Program.cs
public class Balls : MonoBehaviour {
public int num;
public int s;
// Use this for initialization
void Start () {
Renderer rend = GetComponent<Renderer>();
// rend.material.shader = Shader.Find("Specular");
num = System.Convert.ToInt32(GetComponent<SpriteRenderer>().name);
Debug.Log(num);
s = 0;
}
public int c=0;
// Update is called once per frame
void Update ()
{
c = Main.a;
if (num == c)
{
GetComponent<SpriteRenderer>().color = Color.red;
}
else
{
GetComponent<SpriteRenderer>().color = Color.white;
}
}
}
I tried every way that told in forums but i take same error
Object Reference Not Set To An Instance Of An Object
Thank You for your helps…