summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/Scene/LightMapSwitcher.cs
blob: a7433606aef444eb821adc7907d1b3e9ca5d0cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using UnityEngine;

using System.Linq;

public class LightMapSwitcher : MonoBehaviour
{
	//public Texture2D[] DayNear;
	public Texture2D[] DayFar;
	//public Texture2D[] NightNear;
	public Texture2D[] NightFar;
	
	private LightmapData[] dayLightMaps;
	private LightmapData[] nightLightMaps;
	
	void Start ()
	{

		
		// Sort the Day and Night arrays in numerical order, so you can just blindly drag and drop them into the inspector
		//DayNear = DayNear.OrderBy(t2d => t2d.name, new NaturalSortComparer<string>()).ToArray();
		DayFar = DayFar.OrderBy(t2d => t2d.name, new NaturalSortComparer<string>()).ToArray();
		//NightNear = NightNear.OrderBy(t2d => t2d.name, new NaturalSortComparer<string>()).ToArray();
		NightFar = NightFar.OrderBy(t2d => t2d.name, new NaturalSortComparer<string>()).ToArray();
		
		// Put them in a LightMapData structure
		dayLightMaps = new LightmapData[DayFar.Length];
		for (int i=0; i<DayFar.Length; i++)
		{
			dayLightMaps[i] = new LightmapData();
			dayLightMaps[i].lightmapDir = DayFar[i];
			dayLightMaps[i].lightmapColor = DayFar[i];
		}
		
		nightLightMaps = new LightmapData[NightFar.Length];
		for (int i=0; i<NightFar.Length; i++)
		{
			nightLightMaps[i] = new LightmapData();
			nightLightMaps[i].lightmapDir = NightFar[i];
			nightLightMaps[i].lightmapColor = NightFar[i];
		}
	}
	
	#region Publics
	public void SetToDay()
	{
		LightmapSettings.lightmaps = dayLightMaps;
	}
	
	public void SetToNight()
	{
		LightmapSettings.lightmaps = nightLightMaps;
	}
	#endregion
	
	#region Debug
	[ContextMenu ("Set to Night")]
	void Debug00()
	{
		SetToNight();
	}
	
	[ContextMenu ("Set to Day")]
	void Debug01()
	{
		SetToDay();
	}
	#endregion
}