So after searching the whole internet about that question i had to ask it by myself i could find anything. When i play the game in the editor everything works perfect, i get some warnings but nothing serious i think(WARNING: ‘UnityEngine.QualitySettings.currentLevel’ is obsolete. Use GetQualityLevel and SetQualityLevel)
This is my Script;
#pragma strict
static var haveKey = false;
var player : GameObject;
var camera2 : GameObject;
static var keys : int;
var inGame = true;
var inPause = false;
static var menu = false;
static var options = false;
static var CoinShop = false;
var mymenu : boolean;
var myoptions : boolean;
var myCoinshop : boolean;
var Skin2 : GUISkin;
var skin3 : GUISkin;
var skin5 : GUISkin;
var BG : Texture2D;
var normalGUI : GameObject;
var scrollPosition : Vector2 = Vector2.zero;
private var playerMouseLook : MouseLook;
private var playerCameraMouseLook : MouseLook;
var transformation = Matrix4x4.identity;
var Saver : Saver;
var scrollPosition2 : Vector2 = Vector2.zero;
function Start()
{
playerMouseLook = GameObject.Find("Player").GetComponent(MouseLook);
playerCameraMouseLook = GameObject.Find("PlayerCamera").GetComponent(MouseLook);
menu = false;
inPause = false;
}
function OnGUI ()
{
GUI.skin = Skin2;
if(menu == true)
{
if(Input.GetKeyDown(KeyCode.Escape))
{
menu = false;
options = false;
CoinShop = false;
}
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height),BG);
GUI.Label(Rect(Screen.width / 2 - 500, Screen.height / 2 - 500, 1000, 70), "In Game Menu");
GUI.skin = skin5;
if(GUI.Button(Rect(Screen.width / 2 - 250, Screen.height / 2 - 235, 500, 70), "Main Menu"))
{
Application.LoadLevel(1);
}
if(GUI.Button(Rect(Screen.width / 2 - 250, Screen.height / 2 - 135, 500, 70), "Settings"))
{
menu = false;
options = true;
CoinShop = false;
}
if(GUI.Button(Rect(Screen.width / 2 - 250, Screen.height / 2 - 35, 500, 70), "Coin Shop"))
{
CoinShop = true;
menu = false;
options = false;
}
if(GUI.Button(Rect(Screen.width / 2 - 50, Screen.height / 2 + 65, 100, 70), "Save"))
{
Saver.Save();
}
if(GUI.Button(Rect(Screen.width / 2 - 75, Screen.height / 2 + 165, 150, 70), "Resume"))
{
menu = false;
options = false;
}
}
if(CoinShop == true)
{
if(Input.GetKeyDown(KeyCode.Escape))
{
menu = false;
options = false;
CoinShop = false;
}
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), BG);
GUI.Label(Rect(Screen.width / 2 - 250, Screen.height / 2 - 500, 500, 70), "Coin Shop");
GUI.skin = skin5;
GUI.Label(Rect(Screen.width / 2 + 300, Screen.height / 2 - 500, 250, 70), "Coins: " + CoinMaster.Coins);
scrollPosition2 = GUI.BeginScrollView (Rect(Screen.width / 7.5, Screen.height / 7,Screen.width / 1.33,Screen.height / 1.39),scrollPosition2, Rect (0, 0, Screen.width / 1.35, 1400));
if(lightTransporter.myRange == 50)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 - 500, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 - 500, 500, 70), "Coins needed: 1");
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 - 500, 600, 70), "Flashlight Range: " + Math.Round(PlayerPrefs.GetFloat("Range"), 1));
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 - 500, 500, 70), "Flashlight Range") && CoinMaster.Coins >= 1 && lightTransporter.myRange < 50)
{
lightTransporter.myRange += 1;
CoinMaster.Coins -= 1;
}
if(lightTransporter.myIntensity == 2)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 - 400, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 - 400, 600, 70), "Flashlight Intensity: " + Math.Round(PlayerPrefs.GetFloat("Intensity"), 1));
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 - 400, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 - 400, 500, 70), "Flashlight Intensity") && CoinMaster.Coins >= 1 && lightTransporter.myIntensity < 2)
{
lightTransporter.myIntensity += 0.1;
CoinMaster.Coins -= 1;
}
if(lightTransporter.myAngle == 50)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 - 300, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 - 300, 600, 70), "Flashlight Angle: " + Math.Round(PlayerPrefs.GetFloat("Angle"), 1));
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 - 300, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 - 300, 500, 70), "Flashlight Angle") && CoinMaster.Coins >= 1 && lightTransporter.myAngle < 50)
{
lightTransporter.myAngle += 0.1;
CoinMaster.Coins -= 1;
}
if(Flashlight.drainSpeed == 0.1)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 - 200, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 - 200, 600, 70), "Flashlight Life: " + Math.Round(100 / PlayerPrefs.GetFloat("Drainspeed"), 1) + " sec");
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 - 200, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 - 200, 500, 70), "Flashlight life") && CoinMaster.Coins >= 1 && lightTransporter.myDrainspeed > 0.2)
{
CoinMaster.Coins -= 1;
lightTransporter.myDrainspeed -= 0.1;
}
if(lightTransporter.myRange == 150)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 - 100, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 - 100, 600, 70), "Max Stamina: " + Math.Round(PlayerPrefs.GetFloat("maxStamina"), 1) + "%");
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 - 100, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 - 100, 500, 70), "Max Stamina") && CoinMaster.Coins >= 1 && stamina.maxStamina < 100)
{
CoinMaster.Coins -= 1;
stamina.maxStamina += 2;
}
if(stamina.RunStamina == 1)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2, 600, 70), "Run Stamina: " + Math.Round(PlayerPrefs.GetFloat("RunStamina"), 1) + "% sec");
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2, 500, 70), "Run Stamina") && CoinMaster.Coins >= 1 && stamina.RunStamina < -1)
{
CoinMaster.Coins -= 1;
stamina.RunStamina += 0.1;
}
if(stamina.IdleStamina == 15)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 + 100, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 + 100, 600, 70), "Idle Stamina: " + Math.Round(PlayerPrefs.GetFloat("IdleStamina"), 1) + "% sec");
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 + 100, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 + 100, 500, 70), "Idle Stamina") && CoinMaster.Coins >= 1 && stamina.IdleStamina < 15)
{
CoinMaster.Coins -= 1;
stamina.IdleStamina += 0.1;
}
if(lightTransporter.myRange == 10)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 + 200, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 + 200, 600, 70), "Walk Stamina: " + Math.Round(PlayerPrefs.GetFloat("WalkStamina"), 1) + "% sec");
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 + 200, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 + 200, 500, 70), "Walk Stamina") && CoinMaster.Coins >= 1 && stamina.WalkStamina < 10)
{
CoinMaster.Coins -= 1;
stamina.WalkStamina += 0.1;
}
if(stamina.CrouchStamina == 13)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 + 500, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 + 300, 600, 70), "Crouch Stamina: " + Math.Round(PlayerPrefs.GetFloat("CrouchStamina"), 1) + "% sec");
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 + 300, 500, 70), "Coins needed: 1");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 + 300, 500, 70), "Crouch Stamina") && CoinMaster.Coins >= 1 && stamina.CrouchStamina < 13)
{
CoinMaster.Coins -= 1;
stamina.CrouchStamina += 0.1;
}
if(MenuMastering.CoinMulti == 3)
{
GUI.Label(Rect(Screen.width / 4 * 3 - 150, Screen.height / 2 + 500, 110, 70), "Max.");
}
GUI.Label(Rect(Screen.width / 4 * 3 - 752.5, Screen.height / 2 + 500, 600, 70), "Coin Multiplier: " + MenuMastering.CoinMulti);
GUI.Label(Rect(Screen.width / 4 - 512.5, Screen.height / 2 + 500, 500, 70), "Coins needed: 10");
if(GUI.Button(Rect(Screen.width / 4 * 2 - 595, Screen.height / 2 + 500, 500, 70), "Coin Multiplier") && CoinMaster.Coins >= 10 && MenuMastering.CoinMulti < 3)
{
CoinMaster.Coins -= 10;
MenuMastering.CoinMulti += 1;
}
GUI.EndScrollView ();
if(GUI.Button(Rect(Screen.width / 2 - 75, Screen.height / 2 + 450, 150, 70), "Back"))
{
menu = true;
CoinShop = false;
options = false;
}
}
if(options == true)
{
if(Input.GetKeyDown(KeyCode.Escape))
{
menu = false;
options = false;
CoinShop = false;
}
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height),BG);
GUI.skin = skin3;
GUI.Label(Rect(Screen.width / 2 - 155, Screen.height / 15, 310, 70), "Settings");
GUI.skin = skin5;
scrollPosition = GUI.BeginScrollView (Rect(Screen.width / 7.5, Screen.height / 7,Screen.width / 1.33,Screen.height / 1.39),scrollPosition, Rect (0, 0, Screen.width / 1.35, 1400));
GUI.skin = skin5;
GUI.Label(Rect(Screen.width / 2 - 430, Screen.height / 2 - 600 , 170, 70), "Volume");
MenuMastering.myVolume = GUI.HorizontalSlider (Rect (Screen.width / 2 - 650, Screen.height / 2 - 500, 600, 70), MenuMastering.myVolume, 0.0, 1.0);
GUI.Label(Rect(Screen.width / 2 - 595, Screen.height / 2 - 450 , 500, 70), "Texture Quality");
if(GUI.Button(Rect(Screen.width / 5 - 530, Screen.height / 2 - 400, 370, 70), "Full Resolution"))
{
QualitySetter.TextureQuality = 0;
}
if(GUI.Button(Rect(Screen.width / 5 * 2 - 530, Screen.height / 2 - 400, 370, 70), "Half Resolution"))
{
QualitySetter.TextureQuality = 1;
}
if(GUI.Button(Rect(Screen.width / 5 * 3- 555, Screen.height / 2 - 400, 420, 70), "Quarter Resolution"))
{
QualitySetter.TextureQuality = 2;
}
if(GUI.Button(Rect(Screen.width / 5 * 4- 545, Screen.height / 2 - 400, 400, 70), "Eighth Resolution"))
{
QualitySetter.TextureQuality = 3;
}
GUI.Label(Rect(Screen.width / 2 - 595, Screen.height / 2 - 300 , 500, 70), "Anisotropic Textures");
if(GUI.Button(Rect(Screen.width / 4 * 3 - 445, Screen.height / 2 - 250, 200, 70), "Disabled"))
{
QualitySetter.AnisTex = 2;
}
if(GUI.Button(Rect(Screen.width / 4 * 2 - 495, Screen.height / 2 - 250, 300, 70), "Per Texture"))
{
QualitySetter.AnisTex = 1;
}
if(GUI.Button(Rect(Screen.width / 4 * 1 - 495, Screen.height / 2 - 250, 300, 70), "Forced On"))
{
QualitySetter.AnisTex = 0;
}
GUI.Label(Rect(Screen.width / 2 - 595, Screen.height / 2 - 150 , 500, 70), "AntiAliasing");
if(GUI.Button(Rect(Screen.width / 5 * 1 - 380, Screen.height / 2 - 100, 70, 70), "x0"))
{
QualitySetter.AA = 0;
}
if(GUI.Button(Rect(Screen.width / 5 * 2 - 380, Screen.height / 2 - 100, 70, 70), "x2"))
{
QualitySetter.AA = 2;
}
if(GUI.Button(Rect(Screen.width / 5 * 3 - 380, Screen.height / 2 - 100, 70, 70), "x4"))
{
QualitySetter.AA = 4;
}
if(GUI.Button(Rect(Screen.width / 5 * 4 - 380, Screen.height / 2 - 100, 70, 70), "x8"))
{
QualitySetter.AA = 8;
}
GUI.Label(Rect(Screen.width / 2 - 595, Screen.height / 2, 500, 70), "VSync");
if(GUI.Button(Rect(Screen.width / 4 - 380, Screen.height / 2 + 50, 70, 70), "0"))
{
QualitySetter.VSync = 0;
}
if(GUI.Button(Rect(Screen.width / 4 * 2 - 380, Screen.height / 2 + 50, 70, 70), "1"))
{
QualitySetter.VSync = 1;
}
if(GUI.Button(Rect(Screen.width / 4 * 3 - 380, Screen.height / 2 + 50, 70, 70), "2"))
{
QualitySetter.VSync = 2;
}
GUI.Label(Rect(Screen.width / 2 - 595, Screen.height / 2 + 150, 500, 70), "Pixel Light Count");
if(GUI.Button(Rect(Screen.width / 6 * 1 - 380, Screen.height / 2 + 200, 70, 70), "0"))
{
QualitySetter.PixelCount = 0;
}
if(GUI.Button(Rect(Screen.width / 6 * 2 - 380, Screen.height / 2 + 200, 70, 70), "1"))
{
QualitySetter.PixelCount = 1;
}
if(GUI.Button(Rect(Screen.width / 6 * 3 - 380, Screen.height / 2 + 200, 70, 70), "2"))
{
QualitySetter.PixelCount = 2;
}
if(GUI.Button(Rect(Screen.width / 6 * 4 - 380, Screen.height / 2 + 200, 70, 70), "3"))
{
QualitySetter.PixelCount = 3;
}
if(GUI.Button(Rect(Screen.width / 6 * 5 - 380, Screen.height / 2 + 200, 70, 70), "4"))
{
QualitySetter.PixelCount = 4;
}
GUI.Label(Rect(Screen.width / 2 - 595, Screen.height / 2 + 300, 500, 70), "Soft Vegetation");
if(GUI.Button(Rect(Screen.width / 3 - 420, Screen.height / 2 + 350, 150, 70), "True"))
{
QualitySetter.SoftVeg = 1;
}
if(GUI.Button(Rect(Screen.width / 3 * 2 - 420, Screen.height / 2 + 350, 150, 70), "False"))
{
QualitySetter.SoftVeg = 2;
}
GUI.Label(Rect(Screen.width / 2 - 470, Screen.height / 2 + 450, 250, 70), "Fullscreen");
if(GUI.Button(Rect(Screen.width / 3 - 380, Screen.height / 2 + 500, 70, 70), "On"))
{
Screen.fullScreen = true;
}
if(GUI.Button(Rect(Screen.width / 3 * 2 - 380, Screen.height / 2 + 500, 70, 70), "Off"))
{
Screen.fullScreen = false;
}
GUI.Label(Rect(Screen.width / 2 - 445, Screen.height / 2 + 600, 200, 70), "Presets");
if(GUI.Button(Rect(Screen.width / 4 - 425, Screen.height / 2 + 650, 150, 50), "Fastest"))
{
QualitySettings.currentLevel = QualityLevel.Fastest;
}
if(GUI.Button(Rect(Screen.width / 4 * 2 - 400, Screen.height / 2 + 650, 100, 50), "Fast"))
{
QualitySettings.currentLevel = QualityLevel.Fast;
}
if(GUI.Button(Rect(Screen.width / 4 * 3 - 415, Screen.height / 2 + 650, 130, 50), "Simple"))
{
QualitySettings.currentLevel = QualityLevel.Simple;
}
if(GUI.Button(Rect(Screen.width / 4 - 405, Screen.height / 2 + 700, 110, 50), "Good"))
{
QualitySettings.currentLevel = QualityLevel.Good;
}
if(GUI.Button(Rect(Screen.width / 4 * 2 - 445, Screen.height / 2 + 700, 200, 50), "Beautiful"))
{
QualitySettings.currentLevel = QualityLevel.Beautiful;
}
if(GUI.Button(Rect(Screen.width / 4 * 3 - 455, Screen.height / 2 + 700, 210, 50), "Fantastic"))
{
QualitySettings.currentLevel = QualityLevel.Fantastic;
}
GUI.EndScrollView ();
if(GUI.Button(Rect(Screen.width / 2 - 75, Screen.height / 2 + 450, 150, 70), "Back"))
{
menu = true;
CoinShop = false;
options = false;
}
}
}
function Update ()
{
/*if(Input.GetKeyDown(KeyCode.Escape) && menu == false || Input.GetKeyDown(KeyCode.Escape) && CoinShop == false || Input.GetKeyDown(KeyCode.Escape) && options == false)
{
menu = true;
CoinShop = false;
options = false;
Screen.showCursor = true;
}
if(Input.GetKeyDown(KeyCode.Escape) && menu == true || Input.GetKeyDown(KeyCode.Escape) && CoinShop == true || Input.GetKeyDown(KeyCode.Escape) && options == true)
{
menu = false;
CoinShop = false;
options = false;
Screen.showCursor = false;
}*/
if(inPause == false && Input.GetKeyDown(KeyCode.Escape))
{
GotInMenu();
}
if(inPause == true && Input.GetKeyDown(KeyCode.Escape))
{
inPause = false;
GotOutMenu();
}
mymenu = menu;
myCoinshop = CoinShop;
myoptions = options;
/*if(inPause == false)
{
Time.timeScale = 1;
normalGUI.SetActive(true);
Screen.showCursor = false;
} */
}
function GotInMenu()
{
menu = true;
CoinShop = false;
options = false;
Screen.showCursor = true;
normalGUI.SetActive(false);
yield WaitForSeconds(0.1);
inPause = true;
}
function GotOutMenu()
{
menu = false;
CoinShop = false;
options = false;
Screen.showCursor = false;
normalGUI.SetActive(true);
}
sorry for the long script
im working on this project a long time now and i never had this problem so please help and thanks in advance skullbeats1
****Edit:****Well ive put a debug.Log in the (menu == true)and it actually returned me the log so it must be something with the gui’s any ideas??