Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- [System.Serializable]
- public class TimeSettings {
- public string lightMap;
- public Material skyBoxMat;
- public bool fogToggle;
- public Color ambientLight;
- }
- public class StartUpSettings : MonoBehaviour {
- public TimeSettings day;
- public TimeSettings night;
- private TimeSettings currentTimeSettings;
- private bool isDay;
- void Start () {
- Screen.lockCursor = true;
- isDay = true;
- SetLightMaps ();
- }
- void Update () {
- if (Input.GetKeyDown ("q")) {
- SetLightMaps ();
- }
- }
- void SwapLightMaps () {
- }
- void SetLightMaps () {
- // Set the CurrentTimeSettings
- currentTimeSettings = (isDay) ? day : night;
- // Set the RenderSettings to match the CurrentTimeSettings
- RenderSettings.skybox = currentTimeSettings.skyBoxMat;
- RenderSettings.fog = currentTimeSettings.fogToggle;
- RenderSettings.ambientLight = currentTimeSettings.ambientLight;
- // Load the light maps from the Resources folder
- // Pass in the path to the location of the lightmaps, starting below the "Resources" folder.
- LightmapData[] lightMapArray = LightmapSettings.lightmaps;
- for (int i = 0; i < lightMapArray.Length; i++) {
- LightmapData mapData = new LightmapData();
- mapData.lightmapFar = Resources.Load(currentTimeSettings.lightMap + "/LightmapColor-" + i.ToString(), typeof (Texture2D)) as Texture2D;
- mapData.lightmapNear = Resources.Load(currentTimeSettings.lightMap + "/LightmapScale-" + i.ToString(), typeof (Texture2D)) as Texture2D;
- lightMapArray[i] = mapData;
- }
- LightmapSettings.lightmaps = lightMapArray;
- isDay = !isDay;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement