- Home /
'Time' does not contain a definition for 'timeScale'
I have not had problems with this script in the past.. and all of a sudden it has started doing this: 'Time' does not contain a definition for 'timeScale'
using UnityEngine; using System.Collections;
public class PauseScript : MonoBehaviour {
public GameObject transGray;
public GameObject playButton;
public bool paused;
void Start ()
{
paused = false;
playButton.SetActive(false);
transGray.GetComponent<Renderer>().enabled = false;
}
void Update ()
{
}
public void Pause()
{
paused = !paused;
if (paused)
{
Time.timeScale = 0f;
playButton.SetActive(true);
transGray.GetComponent<Renderer>().enabled = true;
}
else if (!paused)
{
Time.timeScale = 1f;
playButton.SetActive(false);;
transGray.GetComponent<Renderer>().enabled = false;
}
}
}
Does anything change if "UnityEngine.Time.timeScale" is used ins$$anonymous$$d?
ummm maybe you are using another library which has a Time class
are you ?
try using UnityEngine.Time.timeScale as suggested
Yes changing it to UnityEngine.Time.timeScale did work :D thanks!!
Answer by tanoshimi · Jul 05, 2015 at 09:12 PM
You've probably named one of your scripts "Time", which is overriding the built-in Time class. Rename the file (and the class definition inside) to something else, like "MyTime".
Your answer
Follow this Question
Related Questions
Pause menu doesn't pause everything 0 Answers
Can you lerp an object when Time.timeScale = 0? 1 Answer
TimeScale = 0 crashes Unity 1 Answer
How to return unity back to its normal time scale and fixedDeltaTime 0 Answers
Time not slowing down on iPhone 3 Answers