Hello, first of all sorry for my bad english … Now, I’m recreating the Slender by a youtuber and the person who is creating not put music on the menu, I decided to get but when I go to Options and change the volume of the game nothing happens in the music menu, just change the rest sound. …: s Can someone help me? Would be internally grateful …
My problem is that I added a song to my menu, but when I go to the game options and methodological higher or lower the music that added nothing happened, only resulted in sounds that I had inserted into the game. Get it? : s
using UnityEngine;
using System.Collections;
public enum Menus{
MainMenu,
Options,
Credits
}
public class MainMenuController : MonoBehaviour {
public Menus currentMenu = Menus.MainMenu;
private float currentVolume = 1;
private float currentSensibility = 10;
public float maxSensibility = 16;
public float minSensibility = 3;
public string textCredits;
public GUISkin guiSkinToUse;
public Texture logoGame;
// Use this for initialization
void Start () {
if(PlayerPrefs.HasKey("CurrentVolume")){
currentVolume = PlayerPrefs.GetFloat("CurrentVolume");
}
else{
PlayerPrefs.SetFloat("CurrentVolume", currentVolume);
}
if(PlayerPrefs.HasKey("CurrentSensibility")){
currentSensibility = PlayerPrefs.GetFloat("CurrentSensibility");
}
else{
PlayerPrefs.SetFloat("CurrentSensibility", currentSensibility);
}
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
GUI.skin = guiSkinToUse;
MenusGame();
}
void MenusGame(){
Vector2 sizeLogo = GetAbsolutePixels(new Vector2(60, 30));
GUI.DrawTexture(new Rect (Screen.width/2-sizeLogo.x/2, 60, sizeLogo.x, sizeLogo.y), logoGame);
switch(currentMenu){
case Menus.MainMenu:{
//
GUILayout.BeginArea(new Rect(Screen.width/2-70, 400, 150, Screen.height));
if(GUILayout.Button("Play")) Application.LoadLevel("GamePlay");
if(GUILayout.Button("Options")) currentMenu = Menus.Options;
if(GUILayout.Button("Credits")) currentMenu = Menus.Credits;
GUILayout.Space (10);
if(GUILayout.Button("Exit")) Application.Quit();
GUILayout.EndArea();
}break;
case Menus.Options:{
//
GUILayout.BeginArea(new Rect(Screen.width/2-70, 400, 150, Screen.height));
GUILayout.Label("Options");
GUILayout.Space(3);
GUILayout.Label("Volume");
currentVolume = GUILayout.HorizontalSlider(currentVolume, 0, 1);
GUILayout.Label("Mouse Sensibility");
currentSensibility = GUILayout.HorizontalSlider(currentSensibility, minSensibility, maxSensibility);
if(GUILayout.Button("Save")) SavePreferens();
GUILayout.Space(10);
if(GUILayout.Button("Back")) currentMenu = Menus.MainMenu;
GUILayout.EndArea();
}break;
case Menus.Credits:{
//
GUILayout.BeginArea(new Rect(Screen.width/2-70, 400, 150, Screen.height));
GUILayout.TextArea(textCredits);
GUILayout.Space(10);
if(GUILayout.Button("Back")) currentMenu = Menus.MainMenu;
GUILayout.EndArea();
}break;
}
}
void SavePreferens(){
PlayerPrefs.SetFloat("CurrentVolume", currentVolume);
PlayerPrefs.SetFloat("CurrentSensibility", currentSensibility);
}
Vector2 GetAbsolutePixels(Vector2 pixels){
Vector2 pixelsAbsolute = Vector2.zero;
pixelsAbsolute.x = pixels.x*Screen.width/100;
pixelsAbsolute.y = pixels.y*Screen.width/100;
return pixelsAbsolute;
}
}