- Home /
This question was
closed Sep 22, 2017 at 07:21 PM by
hexagonius for the following reason:
Posting a question without proper preparation like this is just rude.
Question by
yootob2016 · Sep 22, 2017 at 07:15 PM ·
c#unity 2d
How to add to PlayerPrefs scene & mainmenu unity2d c#
How to add to PlayerPrefs scene & mainmenu unity2d c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ExitScene : MonoBehaviour {
PlayerController player;
public AudioClip winSound;
AudioSource audioS;
// Use this for initialization
void Start () {
audioS = gameObject.GetComponent<AudioSource>();
player = FindObjectOfType<PlayerController>();
}
// Update is called once per frame
void Update () {
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("Player"))
{
audioS.clip = winSound;
audioS.Play();
player.gameObject.GetComponent<Animator>().enabled = false;
player.gameObject.GetComponent<PlayerController>().enabled = false;
Invoke("LoadScene", 4f);
//SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
public void LoadScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex+1);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Menu : MonoBehaviour {
public void LoadPhase(int scene)
{
SceneManager.LoadScene(scene);
}
public void Quit()
{
Application.Quit();
}
public void Mute()
{
AudioListener.pause = !AudioListener.pause;
}
}
Comment
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Scaling unity apps 1 Answer
I have a problem with coins 1 Answer