public void SetResolution(int _value) { float xOffsetCamFollow = 0; switch (_value) { case 0: width = 1024; height = 640; xOffsetCamFollow = 1.7f; break; case 1: width = 1280; height = 720; xOffsetCamFollow = 2.5f; break; case 2: //FIXME: Interact problems at this reso width = 1920; height = 1080; break; } PlayerPrefs.SetInt("reso", _value); Screen.SetResolution(width, height, false); if (GameData.IsInGame) { Camera2DFollow.followControl.listenerObj.transform.localPosition = new Vector3(-xOffsetCamFollow, 1f); //set listenerObj's position to player's pos Camera2DFollow.followControl.xOffset = xOffsetCamFollow; } if (optionsDropDown.value != _value) { optionsDropDown.value = _value; } if (lightingSystem != null) { lightingSystem._renderTargetTexture = new RenderTexture(width, height, -2, RenderTextureFormat.ARGB32); } else { lightingSystem = FindObjectOfType <Light2D.LightingSystem>(); if (lightingSystem != null) { mainCamera = lightingSystem.GetComponent <Camera>(); lightingSystem._renderTargetTexture = new RenderTexture(width, height, -2, RenderTextureFormat.ARGB32); lightingSystem._camera.targetTexture = lightingSystem._renderTargetTexture; } } }
public override void OnInspectorGUI() { // Update the serializedProperty - always do this in the beginning of OnInspectorGUI. serializedObject.Update(); if (Application.isPlaying) { GUI.enabled = false; } LightingSystem lightingSystem = (LightingSystem)target; Camera cam = lightingSystem.GetComponent <Camera>(); bool isMobileTarget = EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS || EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android; if (cam == null) { EditorGUILayout.LabelField("WARNING: No attached camera found."); } EditorGUILayout.PropertyField(_lightPixelSize, new GUIContent("Light Pixel Size")); if (cam != null) { float size; if (cam.orthographic) { size = (cam.orthographicSize + _lightCameraSizeAdd.floatValue) * 2f; } else { float halfFov = (cam.fieldOfView + _lightCameraFovAdd.floatValue) * Mathf.Deg2Rad / 2f; size = Mathf.Tan(halfFov) * _lightObstaclesDistance.floatValue * 2; } if (!Application.isPlaying) { int lightTextureHeight = Mathf.RoundToInt(size / _lightPixelSize.floatValue); int oldSize = lightTextureHeight; lightTextureHeight = EditorGUILayout.IntField("Light Texture Height", lightTextureHeight); if (lightTextureHeight % 2 != 0) { lightTextureHeight++; } if (lightTextureHeight < 16) { if (lightTextureHeight < 8) { lightTextureHeight = 8; } EditorGUILayout.LabelField("WARNING: Light Texture Height is too small."); EditorGUILayout.LabelField(" 50-200 (mobile) and 200-1000 (pc) is recommended."); } if (lightTextureHeight > (isMobileTarget ? 200 : 1000)) { if (lightTextureHeight > 2048) { lightTextureHeight = 2048; } EditorGUILayout.LabelField("WARNING: Light Texture Height is too big."); EditorGUILayout.LabelField(" 50-200 (mobile) and 200-1000 (pc) is recommended."); } if (oldSize != lightTextureHeight) { _lightPixelSize.floatValue = size / lightTextureHeight; } } } if (cam == null || cam.orthographic) { EditorGUILayout.PropertyField(_lightCameraSizeAdd, new GUIContent("Light Camera Size Add")); } else { EditorGUILayout.PropertyField(_lightCameraFovAdd, new GUIContent("Light Camera Fov Add")); EditorGUILayout.PropertyField(_lightObstaclesDistance, new GUIContent("Camera To Light Obstacles Distance")); } EditorGUILayout.PropertyField(_hdr, new GUIContent("64 Bit Color")); EditorGUILayout.PropertyField(_lightObstaclesAntialiasing, new GUIContent("Light Obstacles Antialiasing")); EditorGUILayout.PropertyField(_enableNormalMapping, new GUIContent("Normal Mapping")); if (_enableNormalMapping.boolValue && isMobileTarget) { EditorGUILayout.LabelField("WARNING: Normal mapping is not supported on mobiles."); } _lightTexturesFilterMode.enumValueIndex = (int)(FilterMode)EditorGUILayout.EnumPopup( "Texture Filtering", (FilterMode)_lightTexturesFilterMode.enumValueIndex); EditorGUILayout.PropertyField(_blurLightSources, new GUIContent("Blur Light Sources")); if (_blurLightSources.boolValue && _enableNormalMapping.boolValue) { EditorGUILayout.LabelField(" Blurring light sources with normal mapping enabled\n"); EditorGUILayout.LabelField(" could significantly reduce lighting quality."); } bool normalGuiEnableState = GUI.enabled; if (!_blurLightSources.boolValue) { GUI.enabled = false; } EditorGUILayout.PropertyField(_lightSourcesBlurMaterial, new GUIContent(" Light Sources Blur Material")); GUI.enabled = normalGuiEnableState; EditorGUILayout.PropertyField(_enableAmbientLight, new GUIContent("Enable Ambient Light")); if (!_enableAmbientLight.boolValue) { GUI.enabled = false; } EditorGUILayout.PropertyField(_blurAmbientLight, new GUIContent(" Blur Ambient Light")); bool oldEnabled = GUI.enabled; if (!_blurAmbientLight.boolValue) { GUI.enabled = false; } EditorGUILayout.PropertyField(_ambientLightBlurMaterial, new GUIContent(" Ambient Light Blur Material")); GUI.enabled = oldEnabled; EditorGUILayout.PropertyField(_ambientLightComputeMaterial, new GUIContent(" Ambient Light Compute Material")); GUI.enabled = normalGuiEnableState; EditorGUILayout.PropertyField(_lightOverlayMaterial, new GUIContent("Light Overlay Material")); EditorGUILayout.PropertyField(_lightCamera, new GUIContent("Lighting Camera")); _lightSourcesLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Light Sources Layer"), _lightSourcesLayer.intValue); _lightObstaclesLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Light Obstacles Layer"), _lightObstaclesLayer.intValue); _ambientLightLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Ambient Light Layer"), _ambientLightLayer.intValue); EditorGUILayout.PropertyField(_lightObstaclesReplacementShaderLayer); // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI. serializedObject.ApplyModifiedProperties(); }