- Home /
How do I change scene with two ui canvas text
I want to switch scenes . I am having a problem doing that . I've change the operators and let time reach zero and the scene still dont change. I google the problem and its because ui canvas dont change on web player. This game is for androids and ios. Read about some ui canvas group . I also read about using a but to change scenes. I dont want to use a button . I just want the scenes to switch when the timer reaches zero and the points gotta be lower than the point set. I have scripts save in a document
Answer by Chamandana · Jun 13, 2016 at 07:49 AM
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
public float TimeRemaining = 1;
public string SceneToLoad;
public void Update()
{
if (TimeRemaining > 0) {
TimeRemaining -= Time.deltaTime;
} else {
Application.LoadLevel (SceneToLoad);
}
}
}
Hey try this code, the Timer.cs that I've developed decades ago
No. That script is not going to work . The timer script I got made out works fine . The scene is being change by score and time . I am trying to do that with the Game the script here :
using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.Scene$$anonymous$$anagement; public class Game : $$anonymous$$onoBehaviour {
private $$anonymous$$yClockScript myClock; void Start () { myClock = GetComponent<$$anonymous$$yClockScript>(); }
// Update is called once per frame
void Update () {
if (myClock.m_leftTime < 0 || Game$$anonymous$$anagerSingleton.score > 0)
{
Scene$$anonymous$$anager.LoadScene("ui");
}
}
}
shouldn't you be using scene management? do you have an old version?
No . I tried application load and I get an error. Saying to use scenemanager.
Score script is the singleton script. Would a dontdestroyonload work ?
Answer by RealDragonSlayer03 · Apr 06, 2017 at 07:16 PM
You need to add the using tag "using UnityEngine.SceneManager;" if you want to load different scenes. Once you have that, put "SceneManager.LoadScene("SceneNameGoesHere");". Hope this helped!