using UnityEngine;
using UnityEngine.UI;
using System.Collections;

[ExecuteInEditMode]
[RequireComponent(typeof(Image))]
public class ThemeColoredImage : MonoBehaviour {
	public ThemeColoredSpriteManager theme;
	public ThemeColoredSpriteManager.ColorIndex colorIndex;
	Image img;

	void Reset () {
		if (theme == null) {
			theme = (ThemeColoredSpriteManager)FindObjectOfType (typeof(ThemeColoredSpriteManager));
		}
	}

	void Update () {
		if(img == null ) {
			img = GetComponent<Image> ();
		}

		if (theme == null) {
			theme = (ThemeColoredSpriteManager)FindObjectOfType (typeof(ThemeColoredSpriteManager));
		}

		Color color = theme.ColorFromColorIndex (colorIndex);
		img.color = color;
	}
}
