void Awake() { _postEffect = GetComponent <PostEffect>(); if (_postEffect == null) { Destroy(this); } else { _rawEnabled = _postEffect.enabled; _rawSunShaftsEnabled = _postEffect.SunShaftsEnabled; _rawDOFEnabled = _postEffect.DOFEnabled; _rawBloomEnabled = _postEffect.BloomEnabled; _rawRadialBlurEnabled = _postEffect.RadialBlurEnabled; _rawColorCorrectionEnabled = _postEffect.ColorCorrectionEnabled; _rawVignettingEnabled = _postEffect.VignettingEnabled; _rawSaturationEnable = _postEffect.SaturationEnable; OnChangeQualityLevel(); } }
public override void OnInspectorGUI() { _serializedObj.Update(); PostEffect pe = target as PostEffect; bool isModuleChanged = false; //Color bgColor = GUI.backgroundColor = new Color(.74f, .74f, 1f, 1f); //Color contentColor = GUI.contentColor = new Color(.8f, .8f, 1f, 1f); #if ENABLE_DOF_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_DOFEnabled, new GUIContent("Depth Of Field")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_DOFEnabled.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_DOFForegroundBlur, new GUIContent("Foreground Blur")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } EditorGUILayout.PropertyField(_DOFFocalDistance, new GUIContent("Focal Distance")); EditorGUILayout.PropertyField(_DOFSmoothness, new GUIContent("Smoothness")); EditorGUILayout.PropertyField(_DOFBlurWidth, new GUIContent("Blur Width")); EditorGUILayout.PropertyField(_DOFFocalObject, new GUIContent("Focal Object")); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif #if ENABLE_SUNSHAFT_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_sunShaftsEnabled, new GUIContent("Sun Shafts")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_sunShaftsEnabled.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_sunShaftsScreenBlendMode, new GUIContent("Blend Mode")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(_sunTransform, new GUIContent("Shafts Caster", "Chose a transform that acts as a root point for the produced sun shafts")); if (pe._sunTransform) { if (GUILayout.Button("Move to screen center")) { if (EditorUtility.DisplayDialog("", "" + pe._sunTransform.name + "将被移动到当前摄像机的前方。 确定进行吗? ", "确定", "取消")) { Camera editorCamera = SceneView.currentDrawingSceneView.camera; Ray ray = editorCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); pe._sunTransform.position = ray.origin + ray.direction * 500.0f; pe._sunTransform.LookAt(editorCamera.transform); } } } EditorGUILayout.EndHorizontal(); if (pe._sunTransform) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); _showCrosshair = GUILayout.Toggle(_showCrosshair, "Show Crosshair"); EditorGUILayout.EndHorizontal(); } EditorGUILayout.PropertyField(_sunColor, new GUIContent("Shafts Color")); _sunShaftsMaxRadius.floatValue = 1.0f - EditorGUILayout.Slider("Distance Falloff", 1.0f - _sunShaftsMaxRadius.floatValue, 0, 1); EditorGUILayout.PropertyField(_sunShaftsBlurRadius, new GUIContent("Blur Size")); EditorGUILayout.PropertyField(_sunShaftsIntensity, new GUIContent("Intensity")); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif #if ENABLE_BLOOM_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_bloomEnabled, new GUIContent("Bloom")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_bloomEnabled.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_bloomIntensity, new GUIContent("Intensity")); EditorGUILayout.PropertyField(_bloomThreshhold, new GUIContent("Threshhold")); EditorGUILayout.PropertyField(_bloomBlurWidth, new GUIContent("Blur Width")); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif #if ENABLE_RADIALBLUR_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_radialBlurEnabled, new GUIContent("Radial Blur")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_radialBlurEnabled.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_radialBlurWidth, new GUIContent("Blur Width")); EditorGUILayout.PropertyField(_radialBlurRange, new GUIContent("Blur Range")); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif #if ENABLE_CC_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_colorCorrectionEnabled, new GUIContent("Color Correction")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_colorCorrectionEnabled.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_colorCorrectionMode, new GUIContent("Type")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_colorCorrectionMode.enumValueIndex == (int)PostEffect.ColorCorrectionMode.Simple) { GUILayout.Label("Curves", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_CCRedChannel, new GUIContent(" Red")); EditorGUILayout.PropertyField(_CCGreenChannel, new GUIContent(" Green")); EditorGUILayout.PropertyField(_CCBlueChannel, new GUIContent(" Blue")); if (EditorGUI.EndChangeCheck()) { _serializedObj.ApplyModifiedProperties(); pe.UpdateTextures(); } } else if (_colorCorrectionMode.enumValueIndex == (int)PostEffect.ColorCorrectionMode.Amplify) { EditorGUILayout.PropertyField(_CCLutTexture, new GUIContent("Lut Texture")); } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif #if ENABLE_VIGN_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_vignettingEnabled, new GUIContent("Vignetting")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_vignettingEnabled.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_vignettingIntensity, new GUIContent("Intensity")); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif #if ENABLE_SAT_GUI EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_saturationEnable, new GUIContent("Saturation")); if (EditorGUI.EndChangeCheck()) { isModuleChanged = true; } if (_saturationEnable.boolValue) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_saturation, new GUIContent("Saturation")); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } #endif _serializedObj.ApplyModifiedProperties(); if (isModuleChanged) { pe.EnableShaderKeywords(); } }