/// <summary> /// Setup function /// </summary> private void Start() { //Find time of day component in the scene m_timeOfDay = FindObjectOfType <AmbientSkiesTimeOfDay>(); //If time of day component is not null if (m_timeOfDay != null) { //Sets the render pipeline in this system m_renderPipelineSettings = m_timeOfDay.m_timeOfDayProfile.m_renderPipeline; } }
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 Time Of Day object AmbientSkiesTimeOfDay timeOfDay = (AmbientSkiesTimeOfDay)target; //Monitor for changes EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical("Global Settings", m_boxStyle); GUILayout.Space(20); bool showOptions = m_showOptions; showOptions = EditorGUILayout.Toggle("Show Options", showOptions); AmbientSkiesTimeOfDayProfile todProfile = timeOfDay.m_timeOfDayProfile; if (showOptions) { todProfile = (AmbientSkiesTimeOfDayProfile)EditorGUILayout.ObjectField("Time Of Day Profile", todProfile, typeof(AmbientSkiesTimeOfDayProfile), true); } GUILayout.EndVertical(); //Check for changes, make undo record, make changes and let editor know we are dirty if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(todProfile, "Made camera culling changes"); EditorUtility.SetDirty(todProfile); timeOfDay.m_timeOfDayProfile = todProfile; m_showOptions = showOptions; } }
/// <summary> /// Update function of the emission setup /// </summary> private void Update() { if (m_timeOfDay == null) { //Find time of day component in the scene m_timeOfDay = FindObjectOfType <AmbientSkiesTimeOfDay>(); } //If using sync to time of day system if (m_syncToASTimeOfDay) { //If time of day componenet is null exit if (m_timeOfDay == null) { if (m_showDebugging) { Debug.Log("Missing AmbientSkiesTimeOfDay component in the scene... Exiting system"); } return; } else { //Gets the current stats to see if the sun is active or moon is active m_sunActive = m_timeOfDay.m_sunActive; //If the current time is night if (!m_sunActive) { //Set the emissive status as on m_activestats = true; //Checks to see if the array list has more than one material if (m_emissiveMaterials != null) { //Get all materials that's been assigned in the public materials list foreach (Material mats in m_emissiveMaterials) { //If pipeline is HD if (m_renderPipelineSettings == AmbientSkiesConsts.RenderPipelineSettings.HighDefinition) { //For each one assign the paramater as off mats.SetVector("_EmissiveColor", m_emissiveOn / 10f); } else { //For each one assign the paramater as off mats.SetVector("_EmissionColor", m_emissiveOn / 150f); } } if (m_sceneRenderers.Count > 0) { if (m_renderPipelineSettings == AmbientSkiesConsts.RenderPipelineSettings.HighDefinition) { //Applies the mesh render to the dynamic GI foreach (Renderer renderer in m_sceneRenderers) { //Apply GI to renderer in list DynamicGI.SetEmissive(renderer, m_emissiveOn / 45f); } } else { //Applies the mesh render to the dynamic GI foreach (Renderer renderer in m_sceneRenderers) { //Apply GI to renderer in list DynamicGI.SetEmissive(renderer, m_emissiveOn / 80f); } } } } } //If current time is day else { //Set the emissive status as off m_activestats = false; //Checks to see if the array list has more than one material if (m_emissiveMaterials != null) { //Get all materials that's been assigned in the public materials list foreach (Material mats in m_emissiveMaterials) { //If pipeline is HD if (m_renderPipelineSettings == AmbientSkiesConsts.RenderPipelineSettings.HighDefinition) { //For each one assign the paramater as off mats.SetVector("_EmissiveColor", m_emissiveOff * 0); } else { //For each one assign the paramater as off mats.SetVector("_EmissionColor", m_emissiveOff * 0); } } if (m_sceneRenderers.Count > 0) { //Applies the mesh render to the dynamic GI foreach (Renderer renderer in m_sceneRenderers) { //Apply GI to renderer in list DynamicGI.SetEmissive(renderer, m_emissiveOff / 100); } } } } } } //If not syncing use keycode to switch emission on and off else { //If the button is pressed and the activation status is false if (Input.GetKeyDown(m_emissionOverwriteActivation) && !m_activestats) { //Set the emissive status as on m_activestats = true; //Checks to see if the array list has more than one material if (m_emissiveMaterials != null) { //Get all materials that's been assigned in the public materials list foreach (Material mats in m_emissiveMaterials) { //If pipeline is HD if (m_renderPipelineSettings == AmbientSkiesConsts.RenderPipelineSettings.HighDefinition) { //For each one assign the paramater as off mats.SetVector("_EmissiveColor", m_emissiveOn / 4f); } else { //For each one assign the paramater as off mats.SetVector("_EmissionColor", m_emissiveOn / 7f); } } if (m_sceneRenderers.Count > 0) { //Applies the mesh render to the dynamic GI foreach (Renderer renderer in m_sceneRenderers) { //Apply GI to renderer in list DynamicGI.SetEmissive(renderer, m_emissiveOn); } } //Update the GI DynamicGI.UpdateEnvironment(); } } else if (Input.GetKeyDown(m_emissionOverwriteActivation)) { //Set the emissive status as off m_activestats = false; //Checks to see if the array list has more than one material if (m_emissiveMaterials != null) { //Get all materials that's been assigned in the public materials list foreach (Material mats in m_emissiveMaterials) { //If pipeline is HD if (m_renderPipelineSettings == AmbientSkiesConsts.RenderPipelineSettings.HighDefinition) { //For each one assign the paramater as off mats.SetVector("_EmissiveColor", m_emissiveOff); //For each one assign the paramater as off mats.SetColor("_EmissiveColor", m_emissiveOff); } else { //For each one assign the paramater as off mats.SetVector("_EmissionColor", m_emissiveOff); //For each one assign the paramater as off mats.SetColor("_EmissionColor", m_emissiveOff); } } if (m_sceneRenderers.Count > 0) { //Applies the mesh render to the dynamic GI foreach (Renderer renderer in m_sceneRenderers) { //Apply GI to renderer in list DynamicGI.SetEmissive(renderer, m_emissiveOff); } } //Update the GI DynamicGI.UpdateEnvironment(); } } } }