public override void OnInspectorGUI() { //Initialization //Set up the box style if (m_boxStyle == null) { m_boxStyle = new GUIStyle(GUI.skin.box); m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor; m_boxStyle.fontStyle = FontStyle.Bold; m_boxStyle.alignment = TextAnchor.UpperLeft; } //Get Auto Focus Sky object AutoDepthOfField autoFocus = (AutoDepthOfField)target; //Monitor for changes EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical("Auto Focus Settings", m_boxStyle); GUILayout.Space(20); bool showOptions = m_showOptions; showOptions = EditorGUILayout.Toggle("Show Options", showOptions); AmbientSkiesConsts.DOFTrackingType trackingType = autoFocus.m_trackingType; GameObject targetObject = autoFocus.m_targetObject; Camera sourceCamera = autoFocus.m_sourceCamera; LayerMask targetLayer = autoFocus.m_targetLayer; float focusOffset = autoFocus.m_focusOffset; float maxFocusDistance = autoFocus.m_maxFocusDistance; float actualFocusDistance = autoFocus.m_actualFocusDistance; AmbientPostProcessingProfile postProcessProfile = autoFocus.m_processingProfile; GameObject postProcessingObject = GameObject.Find("Global Post Processing"); if (showOptions) { GUILayout.Space(20); EditorGUILayout.LabelField("Auto Focus Dependencies"); GUILayout.Space(5); sourceCamera = (Camera)EditorGUILayout.ObjectField("Source Camera", sourceCamera, typeof(Camera), true); if (sourceCamera == null) { EditorGUILayout.HelpBox("Source Camera is missing. Either add it manually or it will be added on start of application if present", MessageType.Error); } targetObject = (GameObject)EditorGUILayout.ObjectField("Target Object", targetObject, typeof(GameObject), true); if (targetObject == null) { EditorGUILayout.HelpBox("Target Object is missing. Add it to use target focus mode", MessageType.Error); } targetLayer = LayerMaskField("Target Layer", targetLayer); GUILayout.Space(20); EditorGUILayout.LabelField("Auto Focus Configuration"); GUILayout.Space(5); trackingType = (AmbientSkiesConsts.DOFTrackingType)EditorGUILayout.EnumPopup("Tracking Mode", trackingType); focusOffset = EditorGUILayout.FloatField("Focus Offset", focusOffset); maxFocusDistance = EditorGUILayout.FloatField("Max Focus Distance", maxFocusDistance); actualFocusDistance = EditorGUILayout.FloatField("Actual Focus Distance", actualFocusDistance); if (postProcessProfile == null || postProcessingObject == null) { EditorGUILayout.HelpBox("Ambient Skies Post Processing Profile is not connected. Please load up Ambient Skies window and setup Post Processing", MessageType.Error); } else { EditorGUILayout.HelpBox("Ambient Skies Post Processing Profile is connected. You can now run the scene to use Auto Focus features", MessageType.Info); } } GUILayout.EndVertical(); //Check for changes, make undo record, make changes and let editor know we are dirty if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(autoFocus, "Made camera culling changes"); EditorUtility.SetDirty(autoFocus); m_showOptions = showOptions; autoFocus.m_trackingType = trackingType; autoFocus.m_targetObject = targetObject; autoFocus.m_sourceCamera = sourceCamera; autoFocus.m_targetLayer = targetLayer; autoFocus.m_focusOffset = focusOffset; autoFocus.m_maxFocusDistance = maxFocusDistance; } }
/// <summary> /// Applies the settings to the system /// </summary> /// <param name="profile"></param> public static void SetupMassiveCloudsSystem(AmbientPostProcessingProfile profile) { #if Mewlist_Clouds && UNITY_POST_PROCESSING_STACK_V2 GameObject postProcessVolumeObj = GameObject.Find("Global Post Processing"); PostProcessVolume postProcessVolume; PostProcessProfile processProfile; if (postProcessVolumeObj != null) { postProcessVolume = postProcessVolumeObj.GetComponent <PostProcessVolume>(); if (postProcessVolume != null) { processProfile = postProcessVolume.sharedProfile; if (processProfile != null) { EditorUtility.SetDirty(processProfile); if (profile.massiveCloudsEnabled) { MassiveCloudsEffectSettings massiveClouds; if (!processProfile.TryGetSettings(out massiveClouds)) { if (Application.isPlaying) { Debug.LogWarning("Trying to add 'MassiveCloudsEffectSettings' to " + processProfile + " Unable to add the component in play mode. Please stop the application enable the cloud system then play the application"); profile.massiveCloudsEnabled = false; } else { massiveClouds = processProfile.AddSettings <MassiveCloudsEffectSettings>(); if (processProfile.TryGetSettings(out massiveClouds)) { if (GraphicsSettings.renderPipelineAsset.GetType().ToString().Contains("HDRenderPipelineAsset")) { massiveClouds.IsHDRP.overrideState = true; massiveClouds.IsHDRP.value = true; } else { massiveClouds.IsHDRP.value = false; } massiveClouds.active = true; massiveClouds.BaseColor.overrideState = true; massiveClouds.FogColor.overrideState = true; massiveClouds.Profile.overrideState = true; massiveClouds.SynchronizeBaseColorWithFogColor.overrideState = true; massiveClouds.SynchronizeGlobalFogColor.overrideState = true; massiveClouds.SynchronizeBaseColorWithFogColor.value = profile.syncBaseFogColor; massiveClouds.SynchronizeGlobalFogColor.value = profile.syncGlobalFogColor; massiveClouds.FogColor.value = profile.cloudsFogColor; massiveClouds.BaseColor.value = profile.cloudsBaseFogColor; if (massiveClouds.Profile.value == null) { massiveClouds.Profile.value = AssetDatabase.LoadAssetAtPath <MassiveCloudsProfile>(SkyboxUtils.GetAssetPath("SolidRich")); profile.cloudProfile = massiveClouds.Profile.value; } else { massiveClouds.Profile.value = profile.cloudProfile; } } } } else { if (processProfile.TryGetSettings(out massiveClouds)) { massiveClouds.active = true; massiveClouds.BaseColor.overrideState = true; massiveClouds.FogColor.overrideState = true; massiveClouds.Profile.overrideState = true; massiveClouds.SynchronizeBaseColorWithFogColor.overrideState = true; massiveClouds.SynchronizeGlobalFogColor.overrideState = true; massiveClouds.SynchronizeBaseColorWithFogColor.value = profile.syncBaseFogColor; massiveClouds.SynchronizeGlobalFogColor.value = profile.syncGlobalFogColor; massiveClouds.FogColor.value = profile.cloudsFogColor; massiveClouds.BaseColor.value = profile.cloudsBaseFogColor; massiveClouds.Profile.value = profile.cloudProfile; } } } else { MassiveCloudsEffectSettings massiveClouds; if (Application.isPlaying) { if (processProfile.TryGetSettings(out massiveClouds)) { massiveClouds.active = false; } } else { if (processProfile.TryGetSettings(out massiveClouds)) { processProfile.RemoveSettings <MassiveCloudsEffectSettings>(); } } } } } } #endif }