Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Rafael10 · Mar 16, 2014 at 03:10 PM · music

Change the volume of the music menu

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 ...

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rafael10 · Mar 16, 2014 at 03:48 PM 0
Share

Please someone help me...

avatar image robertbu · Mar 16, 2014 at 04:27 PM 0
Share

I'm not sure what you are asking. Posting the code you use to show the menu, attempt to change the volume and play the sound might help.

avatar image Rafael10 · Mar 16, 2014 at 08:14 PM 0
Share

$$anonymous$$y 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 $$anonymous$$enus{ $$anonymous$$ain$$anonymous$$enu, Options, Credits }

public class $$anonymous$$ain$$anonymous$$enuController : $$anonymous$$onoBehaviour {

public $$anonymous$$enus current$$anonymous$$enu = $$anonymous$$enus.$$anonymous$$ain$$anonymous$$enu; private float currentVolume = 1; private float currentSensibility = 10; public float maxSensibility = 16; public float $$anonymous$$Sensibility = 3; public string textCredits;

public GUISkin guiSkinToUse;

public Texture logoGame;

// Use this for initialization void Start () { if(PlayerPrefs.Has$$anonymous$$ey("CurrentVolume")){ currentVolume = PlayerPrefs.GetFloat("CurrentVolume"); } else{ PlayerPrefs.SetFloat("CurrentVolume", currentVolume); }

 if(PlayerPrefs.Has$$anonymous$$ey("CurrentSensibility")){
    currentSensibility = PlayerPrefs.GetFloat("CurrentSensibility");
 }
 else{
    PlayerPrefs.SetFloat("CurrentSensibility", currentSensibility);
 }
 

}

// Update is called once per frame void Update () {

}

void OnGUI(){ GUI.skin = guiSkinToUse; $$anonymous$$enusGame(); }

void $$anonymous$$enusGame(){

 Vector2 sizeLogo = GetAbsolutePixels(new Vector2(60, 30));
 
 GUI.DrawTexture(new Rect (Screen.width/2-sizeLogo.x/2, 60, sizeLogo.x, sizeLogo.y), logoGame);
 
 switch(current$$anonymous$$enu){
 case $$anonymous$$enus.$$anonymous$$ain$$anonymous$$enu:{
    //
    GUILayout.BeginArea(new Rect(Screen.width/2-70, 400, 150, Screen.height));
    if(GUILayout.Button("Play")) Application.LoadLevel("GamePlay");
    if(GUILayout.Button("Options")) current$$anonymous$$enu = $$anonymous$$enus.Options;
    if(GUILayout.Button("Credits")) current$$anonymous$$enu = $$anonymous$$enus.Credits;
    GUILayout.Space (10);
    if(GUILayout.Button("Exit")) Application.Quit();
    GUILayout.EndArea();
 }break;
 case $$anonymous$$enus.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("$$anonymous$$ouse Sensibility");
    currentSensibility = GUILayout.HorizontalSlider(currentSensibility, $$anonymous$$Sensibility, maxSensibility);
    if(GUILayout.Button("Save")) SavePreferens();
    GUILayout.Space(10);
    if(GUILayout.Button("Back")) current$$anonymous$$enu = $$anonymous$$enus.$$anonymous$$ain$$anonymous$$enu;
    GUILayout.EndArea();
 }break;
 case $$anonymous$$enus.Credits:{
    //
    GUILayout.BeginArea(new Rect(Screen.width/2-70, 400, 150, Screen.height));
    GUILayout.TextArea(textCredits);
    GUILayout.Space(10);
    if(GUILayout.Button("Back")) current$$anonymous$$enu = $$anonymous$$enus.$$anonymous$$ain$$anonymous$$enu;
    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;

}

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Rafael10 · Mar 16, 2014 at 05:48 PM

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;
 }

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

spheres not colliding with world 1 Answer

I can't import anything in Unity!. 1 Answer

Need help with playing audio on click. 3 Answers

FPS Multiplayer Help 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges