Here is the script :
using UnityEngine;
using System.Collections;
public class Cube_01 : MonoBehaviour
{
public GameObject C1;
GameObject Camera_Man = GameObject.Find ("Camera_Man");
CubeChange Cube1 = Camera_Man.GetComponent<CubeChange> ();
void Start ()
{
C1.activeSelf = false;
}
void Update ()
{
if (Cube1.CubeNumber = 1) {
C1.activeSelf = true;
}
}
}
I am trying to make a game where when a button is pressed It makes one object active and all the rest inactive.
BUT,
I get the error : A field initializer cannot reference the nonstatic field, method, or property `Cube_01.Camera_Man’
Ive looked up a couple of ways how to solve this and all of the fixes I saw were to put :
GameObject Camera_Man = GameObject.Find (“Camera_Man”);
CubeChange Cube1 = Camera_Man.GetComponent ();
Into the start Method. Unfortunately when I do that I get a whole different set of errors.
Thank you for your time
Brandon.