[text] Menu

Viewer

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class Menu : MonoBehaviour
  8. {
  9.      public AudioClip audioKlik;
  10.      private AudioSource MediaPlayerKlik;
  11.      
  12.  
  13.     // Method untuk memulai permainan
  14. void Start () {
  15.         MediaPlayerKlik = gameObject.AddComponent<AudioSource>();
  16.         MediaPlayerKlik.clip = audioKlik;
  17.         }
  18.  
  19.     public void StartButton(string gamePlayScene)
  20.     {
  21.         SceneManager.LoadScene(gamePlayScene);
  22.         MediaPlayerKlik.Play();
  23.     }
  24.  
  25.     // Method untuk membuka scene credit
  26.     public void CreditButton(string creditScene)
  27.     {
  28.         SceneManager.LoadScene(creditScene);
  29.         MediaPlayerKlik.Play();
  30.     }
  31.  
  32.     // Method untuk keluar dari game
  33.     public void ExitGame()
  34.     {
  35.         #if UNITY_EDITOR
  36.             UnityEditor.EditorApplication.isPlaying = false;
  37.         #else
  38.             Application.Quit();
  39.         #endif
  40.         MediaPlayerKlik.Play();
  41.     }
  42. }
  43.  

Editor

You can edit this paste and save as new:


File Description
  • Menu
  • Paste Code
  • 29 Apr-2024
  • 1.02 Kb
You can Share it: