using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[CustomEditor(typeof(LightDesk))]
public class LightDeskInspector : Editor {
	
	LightDesk Target;
	
	void OnEnable ()
	{
		Target = target as LightDesk;
	}
	
	public override void OnInspectorGUI ()
	{
		DrawDefaultInspector();
		
		serializedObject.Update();
		
		EditorGUILayout.BeginVertical("box");
		
		if (Target.houseLights != null && Target.houseLights.Length > 0)
		{
			EditorGUILayout.LabelField("House Lights", new GUIStyle("box"));
			for (int i = 0; i < Target.houseLights.Length; i++)
				Target.houseLights[i].GetComponent<Light>().intensity = 
					EditorGUILayout.FloatField(Target.houseLights[i].ToString(),
						Target.houseLights[i].GetComponent<Light>().intensity);
		}
		
		if (Target.downstageLamps != null && Target.downstageLamps.Length > 0)
		{
			EditorGUILayout.LabelField("Downstage Lamps", new GUIStyle("box"));
			for (int i = 0; i < Target.downstageLamps.Length; i++)
				Target.downstageLamps[i].GetComponentInChildren<Light>().intensity = 
					EditorGUILayout.FloatField(Target.downstageLamps[i].ToString(),
						Target.downstageLamps[i].GetComponentInChildren<Light>().intensity);
		}
		
		if (Target.onstageSpots != null && Target.onstageSpots.Length > 0)
		{
			EditorGUILayout.LabelField("Onstage Spotlamps", new GUIStyle("box"));
			for (int i = 0; i < Target.onstageSpots.Length; i++)
				Target.onstageSpots[i].light.intensity = 
					EditorGUILayout.FloatField(Target.onstageSpots[i].ToString(),
						Target.onstageSpots[i].light.intensity);
		}
		
		if (Target.offstageSpots != null && Target.offstageSpots.Length > 0)
		{
			EditorGUILayout.LabelField("Offstage Spotlamps", new GUIStyle("box"));
			for (int i = 0; i < Target.offstageSpots.Length; i++)
				Target.offstageSpots[i].light.intensity = 
					EditorGUILayout.FloatField(Target.offstageSpots[i].ToString(),
						Target.offstageSpots[i].light.intensity);
		}
		
		EditorGUILayout.EndVertical();
		
		serializedObject.ApplyModifiedProperties();
	}


}
