- Home /
UnassignedReferenceException for assigned variable
I'm having a problem with Unity 4.3. I seem to be getting these errors:
All of them are the same. Normally, this wouldn't be a big deal; I would just set the value of pauseButton (a SpriteRenderer) in the Inspector. There's one problem, though:
I did set the value in the Inspector. And the errors continue. Does anyone know what is going on? Any help would be greatly appreciated.
That screenshot of the inspector window showing pauseButton assigned - is that taken while the game is running? (and the errors are co$$anonymous$$g up?)
All right. Since the script is too long to show in its entirety, I'll just show the parts that concern the variable in question, using ellipses to represent parts that I removed.
public class Player : $$anonymous$$onoBehaviour {
...
public SpriteRenderer pauseButton;
private Vector3 pauseButtonPosition;
private Vector3 newPauseButtonPosition;
public bool paused;
...
// Use this for initialization
protected void Start () {
...
pauseButtonPosition = new Vector3(-25f,-45f);
paused = false;
...
}
// Update is called once per frame
protected void Update () {
...
newPauseButtonPosition.Set(pauseButtonPosition.x + tiltAngle, pauseButtonPosition.y - speed, pauseButtonPosition.z); // Because the pause button is a sprite, it has to move with the camera
...
pauseButton.transform.position = Vector3.Lerp(pauseButtonPosition, newPauseButtonPosition, (Time.time - startTime) / duration); // $$anonymous$$ove the pause button sprite
...
}
There are more methods, but they do not use the variable in question at all.
tanoshimi: No, it is not. The screenshot is the same while it is running, though.
I apologize for taking so long to respond; I just now saw your comment.
Answer by CrossRiverGames · Jan 07, 2014 at 05:02 PM
The problem appears to have solved itself; the errors no longer appear.