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 Horizon Sky object HorizonSky horizonSky = (HorizonSky)target; //Monitor for changes EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical("Horizon Sky Configuration", m_boxStyle); GUILayout.Space(20); bool showOptions = m_showOptions; showOptions = EditorGUILayout.Toggle("Show Options", showOptions); float positionUpdate = horizonSky.m_positionUpdate; bool followCamera = horizonSky.m_followsCameraPosition; if (showOptions) { positionUpdate = EditorGUILayout.FloatField("Position Update Time", positionUpdate); followCamera = EditorGUILayout.Toggle("Follow Camera", followCamera); } GUILayout.EndVertical(); //Check for changes, make undo record, make changes and let editor know we are dirty if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(horizonSky, "Made camera culling changes"); EditorUtility.SetDirty(horizonSky); m_showOptions = showOptions; horizonSky.m_positionUpdate = positionUpdate; horizonSky.m_followsCameraPosition = followCamera; } }
/// <summary> /// Applies the settings to the horizons material and gameobject /// </summary> /// <param name="profile"></param> /// <param name="horizonMaterial"></param> public static void ApplyHorizonSettings(AmbientSkyProfiles skyProfiles, AmbientSkyboxProfile profile, AmbientProceduralSkyboxProfile proceduralProfile, Material horizonMaterial) { if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientHDRISkies) { horizonMaterial.SetFloat("_Scattering", profile.horizonScattering); horizonMaterial.SetFloat("_FogDensity", profile.horizonFogDensity); horizonMaterial.SetFloat("_HorizonFalloff", profile.horizonFalloff); horizonMaterial.SetFloat("_HorizonBlend", profile.horizonBlend); if (horizonSkyObject == null) { horizonSkyObject = GameObject.Find("Ambient Skies Horizon"); if (profile.scaleHorizonObjectWithFog && profile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(profile.fogDistance, profile.fogDistance * 1.2f, profile.fogDistance); } else { horizonSkyObject.transform.localScale = profile.horizonSize; } if (!profile.followPlayer) { horizonSkyObject.transform.position = profile.horizonPosition; } } else { if (profile.scaleHorizonObjectWithFog && profile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(profile.fogDistance, profile.fogDistance * 1.2f, profile.fogDistance); } else { horizonSkyObject.transform.localScale = profile.horizonSize; } if (!profile.followPlayer) { horizonSkyObject.transform.position = profile.horizonPosition; } } if (horizonSettings == null) { horizonSettings = Object.FindObjectOfType <HorizonSky>(); horizonSettings.m_followsCameraPosition = profile.followPlayer; horizonSettings.m_positionUpdate = profile.horizonUpdateTime; horizonSettings.UpdatePosition(); } else { horizonSettings.m_followsCameraPosition = profile.followPlayer; horizonSettings.m_positionUpdate = profile.horizonUpdateTime; horizonSettings.UpdatePosition(); } } else if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientProceduralSkies) { horizonMaterial.SetFloat("_Scattering", proceduralProfile.horizonScattering); horizonMaterial.SetFloat("_FogDensity", proceduralProfile.horizonFogDensity); horizonMaterial.SetFloat("_HorizonFalloff", proceduralProfile.horizonFalloff); horizonMaterial.SetFloat("_HorizonBlend", proceduralProfile.horizonBlend); if (horizonSkyObject == null) { horizonSkyObject = GameObject.Find("Ambient Skies Horizon"); if (proceduralProfile.scaleHorizonObjectWithFog && proceduralProfile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(proceduralProfile.proceduralFogDistance, proceduralProfile.proceduralFogDistance * 1.2f, proceduralProfile.proceduralFogDistance); } else { horizonSkyObject.transform.localScale = proceduralProfile.horizonSize; } if (!proceduralProfile.followPlayer) { horizonSkyObject.transform.position = proceduralProfile.horizonPosition; } } else { if (proceduralProfile.scaleHorizonObjectWithFog && proceduralProfile.fogType == AmbientSkiesConsts.VolumeFogType.Linear) { horizonSkyObject.transform.localScale = new Vector3(proceduralProfile.proceduralFogDistance, proceduralProfile.proceduralFogDistance * 1.2f, proceduralProfile.proceduralFogDistance); } else { horizonSkyObject.transform.localScale = proceduralProfile.horizonSize; } if (!proceduralProfile.followPlayer) { horizonSkyObject.transform.position = proceduralProfile.horizonPosition; } } if (horizonSettings == null) { horizonSettings = Object.FindObjectOfType <HorizonSky>(); horizonSettings.m_followsCameraPosition = proceduralProfile.followPlayer; horizonSettings.m_positionUpdate = proceduralProfile.horizonUpdateTime; horizonSettings.UpdatePosition(); } else { horizonSettings.m_followsCameraPosition = proceduralProfile.followPlayer; horizonSettings.m_positionUpdate = proceduralProfile.horizonUpdateTime; horizonSettings.UpdatePosition(); } } }