- Home /
Question by
palboy · Apr 12, 2014 at 08:45 AM ·
c#nullreferenceexceptiongetcomponenttimescale
Object reference not set to an instance of an object in c#.
Hi guys! I have some problems with script. I want my game to start after i press on the screen, if i dont press on the screen i want my game not to start. I hope you understand what i mean.
this is my script
using UnityEngine;
using System.Collections;
public class StartScreen1 : MonoBehaviour {
public bool sawOnce = false;
void Start () {
if (!sawOnce) {
GetComponent<SpriteRenderer>().enabled = true;
Time.timeScale = 0;
}
sawOnce = true;
}
void Update () {
if (Time.timeScale == 0 && (Input.GetMouseButtonDown (0))) {
Time.timeScale = 1;
GetComponent<SpriteRenderer>().enabled = false;
Destroy(this.gameObject);
}
}
}
but this script don't working. My game starts without press. Help please
Comment
Your answer
Follow this Question
Related Questions
NullReferenceException when trying to access other GO in script. C# 1 Answer
I'm having more problems accessing a variable from another script in c# 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Still strugging with GetComponent and accessing other objects (C#) 2 Answers