void ChangeShaderDetails(E_ShaderDetails level) { GraphicsDetailsUtl.DisableShaderKeyword("UNITY_SHADER_DETAIL_LOW"); GraphicsDetailsUtl.DisableShaderKeyword("UNITY_SHADER_DETAIL_MEDIUM"); GraphicsDetailsUtl.DisableShaderKeyword("UNITY_SHADER_DETAIL_HIGH"); switch (level) { case E_ShaderDetails.E_SHADER_DETAILS_LOW: { GraphicsDetailsUtl.EnableShaderKeyword("UNITY_SHADER_DETAIL_LOW"); } break; case E_ShaderDetails.E_SHADER_DETAILS_MEDIUM: { GraphicsDetailsUtl.EnableShaderKeyword("UNITY_SHADER_DETAIL_MEDIUM"); } break; case E_ShaderDetails.E_SHADER_DETAILS_HIGH: { GraphicsDetailsUtl.EnableShaderKeyword("UNITY_SHADER_DETAIL_HIGH"); } break; } }
static void SetPerformanceLevel(Performance perfLevel) { //Application.targetFrameRate = 30; Screen.sleepTimeout = SleepTimeout.NeverSleep; //Debug.Log("Set Quality Settings - " + perfLevel); switch (perfLevel) { case Performance.UltraHigh: //RenderSettings.fog = true; GraphicsDetailsUtl.SetShaderQuality(GraphicsDetailsUtl.Quality.High); QualitySettings.SetQualityLevel(System.Array.IndexOf(QualitySettings.names, m_UnityQualityProfileName_UltraHigh), true); QualitySettings.masterTextureLimit = 0; break; case Performance.High: //RenderSettings.fog = true; GraphicsDetailsUtl.SetShaderQuality(GraphicsDetailsUtl.Quality.High); QualitySettings.SetQualityLevel(System.Array.IndexOf(QualitySettings.names, m_UnityQualityProfileName_High), true); QualitySettings.masterTextureLimit = 0; break; case Performance.Medium: //RenderSettings.fog = false; GraphicsDetailsUtl.SetShaderQuality(GraphicsDetailsUtl.Quality.Medium); QualitySettings.SetQualityLevel(System.Array.IndexOf(QualitySettings.names, m_UnityQualityProfileName_Medium), true); QualitySettings.masterTextureLimit = 0; break; default: // Performance.Low: //RenderSettings.fog = false; GraphicsDetailsUtl.SetShaderQuality(GraphicsDetailsUtl.Quality.Low); QualitySettings.SetQualityLevel(System.Array.IndexOf(QualitySettings.names, m_UnityQualityProfileName_Low), true); QualitySettings.masterTextureLimit = 1; break; } }
public static Performance GetDetectedPerformanceLevel() { #if UNITY_EDITOR return(DeviceInfo.Performance.High); // high details for EDITOR #elif UNITY_IPHONE if (UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhone5 || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhone5C || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPad4Gen) { return(DeviceInfo.Performance.UltraHigh); } else if (UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPad3Gen || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhone4S || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPad2Gen || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPadMini1Gen || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPodTouch5Gen) { return(DeviceInfo.Performance.Medium); } else if (UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhone4 || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPodTouch4Gen || UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPad1Gen) { return(DeviceInfo.Performance.Low); } //5S, iPadAir, iPadmini2 return(DeviceInfo.Performance.UltraHigh); //all unknown devices (probably any new ones) #elif UNITY_ANDROID if (GraphicsDetailsUtl.IsTegra3()) { return(DeviceInfo.Performance.High); // high details for TEGRA 3 } else { return(DeviceInfo.Performance.Low); //TODO: choose proper details based on actual device performance } #elif UNITY_STANDALONE if (SystemInfo.graphicsShaderLevel >= 30 && SystemInfo.processorCount >= 2 && SystemInfo.graphicsMemorySize >= 512 && SystemInfo.systemMemorySize >= 4096) { return(DeviceInfo.Performance.UltraHigh); } else if (SystemInfo.graphicsMemorySize >= 256 && SystemInfo.systemMemorySize >= 2048) { return(DeviceInfo.Performance.High); } else if (SystemInfo.graphicsMemorySize >= 128 && SystemInfo.systemMemorySize >= 1024) { return(DeviceInfo.Performance.Medium); } return(DeviceInfo.Performance.Low); #else return(DeviceInfo.Performance.Low); #endif }
void Awake() { BuildInfo.DrawVersionInfo = false; // 1366x720=983520 // 1024x720=737280 // 900x640=614400 //Screen.SetResolution (1024, 540, true); //new Texture().SetAnisotropicFilteringLimits(1,1);//2,2); // // warmup post-fx shaders // /* * if (iPhoneSettings.generation == iPhoneGeneration.iPodTouch3Gen || iPhoneSettings.generation == iPhoneGeneration.iPodTouch4Gen || iPhoneSettings.generation == iPhoneGeneration.iPhone3GS || iPhoneSettings.generation == iPhoneGeneration.iPad1Gen) * QualitySettings.masterTextureLimit = 1; * * if (iPhoneSettings.generation == iPhoneGeneration.iPad2Gen) * QualitySettings.antiAliasing = 4; */ //CamExplosionFXMgr.PreloadResources(); GraphicsDetailsUtl.DisableShaderKeyword("UNITY_IPHONE"); #if UNITY_IPHONE GraphicsDetailsUtl.EnableShaderKeyword("UNITY_IPHONE"); #endif #if UNITY_ANDROID && !UNITY_EDITOR try { MogaGamepad.Init(); MogaGamepad.OnConnectionChange += OnMogaConnectionChange; MogaGamepad.OnBatteryLowChange = OnMogaBatteryLowChange; if (m_IsFocused) { //Debug.Log("Moga: Application focused"); MogaGamepad.OnFocus(m_IsFocused); } } catch (System.Exception) {} #endif QualitySettings.masterTextureLimit = 0; if (_Instance) { if (_Instance.Client == null) { _Instance.Client = Client; } Destroy(this.gameObject); return; } else { _Instance = this; uLink.NetworkView nw = GetComponent <uLink.NetworkView>(); if (nw != null) { // This workaround fixes the warning about alredy registered manual ID // Now the NetworkView is registered only once (using given ManualViewIDWorkaround). nw.SetManualViewID(ManualViewIDWorkaround); } } CloudUser.authenticationChanged += OnUserAuthenticationChanged; GamepadInputManager.CreateInstance(); DontDestroyOnLoad(this); this.transform.parent = null; InputManager.Initialize(); if (AppType == E_AppType.DedicatedServer) { Application.targetFrameRate = 60; } else { Application.targetFrameRate = 30; } // test server optimization // not really great optimization I would say... (our servers were definitelly more laggy) // Changing back to 60FPS on the server //Application.targetFrameRate = 30; uLink.BitStreamCodec.Add <PlayerPersistantInfo>(PlayerPersistantInfo.Deserialize, PlayerPersistantInfo.Serialize); uLink.BitStreamCodec.Add <PPIInventoryList>(PPIInventoryList.Deserialize, PPIInventoryList.Serialize); uLink.BitStreamCodec.Add <PPIEquipList>(PPIEquipList.Deserialize, PPIEquipList.Serialize); uLink.BitStreamCodec.Add <PPIRoundScore>(PPIRoundScore.Deserialize, PPIRoundScore.Serialize); uLink.BitStreamCodec.Add <PPIUpgradeList>(PPIUpgradeList.Deserialize, PPIUpgradeList.Serialize); uLink.BitStreamCodec.Add <PPIOutfits>(PPIOutfits.Deserialize, PPIOutfits.Serialize); uLink.BitStreamCodec.Add <RoundFinalResult>(RoundFinalResult.Deserialize, RoundFinalResult.Serialize); uLink.BitStreamCodec.AddAndMakeArray <RoundFinalResult.PlayerResult>(RoundFinalResult.PlayerResult.Deserialize, RoundFinalResult.PlayerResult.Serialize); #if UNITY_IPHONE || UNITY_ANDROID Screen.autorotateToPortrait = false; Screen.autorotateToPortraitUpsideDown = false; #endif Screen.sleepTimeout = 120; // // experimental networking stuff // if (AppType == E_AppType.Game && Application.isEditor == false) { // initialize plugins EtceteraWrapper.Init(); if (TwitterConfiguration.IsAvailable) { TwitterWrapper.Init(TwitterConfiguration.CustomerKey, TwitterConfiguration.CustomerSecret); } if (ChartBoostConfiguration.IsAvailable) { ChartBoost.init(ChartBoostConfiguration.AppId, ChartBoostConfiguration.AppSignature); } if (TapJoyConfiguration.IsAvailable) { TapJoy.Init(TapJoyConfiguration.AppId, TapJoyConfiguration.SecurityKey); } } // Synchronize item settings managers with cloud SettingsCloudSync.GetInstance().UpdateSettingsManagersFromCloud(); LastTouchControlTime = 0; }