Advertisement
Guest User

Options C# Unity

a guest
Mar 7th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.74 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Option : MonoBehaviour
  5. {
  6.     private bool openoption = false;
  7.     private bool showsoundslider = false;
  8.  
  9.     public float buttonWidth = 100;
  10.     public float buttonHeight = 30;
  11.  
  12.     public float SoundEffect = 5.0f;
  13.  
  14.     private bool showgraphics = false;
  15.     // Use this for initialization
  16.     void Start()
  17.     {
  18.  
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.     //tu mam problem
  25.         Antialiasing Ant = gameObject.GetComponentInParent<Antialiasing>();
  26.     //tu mam problem      
  27.  
  28.         // Zaczynamy Wyciszać dźwięki
  29.         AudioSource As = gameObject.GetComponent<AudioSource>();
  30.  
  31.         if (SoundEffect < 5.0f)
  32.         {
  33.             As.volume = 0.8f;
  34.         }
  35.         else if (SoundEffect == 5.0f)
  36.         {
  37.             As.volume = 1.0f;
  38.         }
  39.  
  40.         if (SoundEffect < 4.0f)
  41.         {
  42.             As.volume = 0.6f;
  43.         }
  44.         else if (SoundEffect == 4.0f)
  45.         {
  46.             As.volume = 0.8f;
  47.         }
  48.  
  49.         if (SoundEffect < 3.0f)
  50.         {
  51.             As.volume = 0.4f;
  52.         }
  53.         else if (SoundEffect == 3.0f)
  54.         {
  55.             As.volume = 0.6f;
  56.         }
  57.  
  58.         if (SoundEffect < 2.0f)
  59.         {
  60.             As.volume = 0.2f;
  61.         }
  62.         else if (SoundEffect == 2.0f)
  63.         {
  64.             As.volume = 0.4f;
  65.         }
  66.  
  67.         if (SoundEffect < 1.0f)
  68.         {
  69.             As.volume = 0.0f;
  70.         }
  71.         else if (SoundEffect == 1.0f)
  72.         {
  73.             As.volume = 0.2f;
  74.         }
  75.         // Kończymy Wyciszać Dzwięki
  76.     }
  77.     void OnGUI()
  78.     {
  79.         if (GUI.Button(new Rect(50, 400, buttonWidth, buttonHeight), "Opcje"))
  80.         {
  81.             openoption = !openoption;
  82.         }
  83.         if (openoption)
  84.         {
  85.             if (GUI.Button(new Rect(700, 400, buttonWidth, buttonHeight), "Graficzne"))
  86.             {
  87.                 showgraphics = !showgraphics;
  88.             }
  89.  
  90.             if (GUI.Button(new Rect(400, 400, buttonWidth, buttonHeight), "Dzwięki"))
  91.             {
  92.                 showsoundslider = !showsoundslider;
  93.  
  94.             }
  95.             if (showsoundslider)
  96.             {
  97.                 SoundEffect = GUI.VerticalSlider(new Rect(400, 500, 30, 100), SoundEffect, 5.0F, 0.0F);
  98.                 GUI.Label(new Rect(420, 490, 10, 160), "Muzyka");
  99.             }
  100.             if (showgraphics)
  101.             {
  102.                 GUI.Label(new Rect(700, 460, 100, 50), "Jakość :");
  103.                 if (GUI.Button(new Rect(770, 460, 100, 30), "Niska"))
  104.                 {
  105.  
  106.                 }
  107.  
  108.                 if (GUI.Button(new Rect(870, 460, 100, 30), "Wysoka"))
  109.                 {
  110.  
  111.                 }
  112.             }
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement