Inheritance: UIBaseObject
		void Awake()
		{
			if (Application.isPlaying)
			{
				uiChartPie = (UIChartPie)UIManager.Instance.Add(type, gameObject, "");
				uiChartPie.SortingOrder = sortingOrder;				
				uiChartPie.scrollArea = scrollArea;
			}
		}
		void Awake()
		{
			if (Application.isPlaying)
			{
				// Debug.Log(gameObject.name+ " <color=red>Init</color>");
				// Debug.Log("transform:" + gameObject.transform);

				uiChartPie = (UIChartPie)UIManager.Instance.Add(type, gameObject, "");
				uiChartPie.SortingOrder = sortingOrder;				
				uiChartPie.scrollArea = scrollArea;
			}
		}
        void Awake()
        {
            Debug.Log("PieExample Awake");
            ChartPie c = gameObject.GetComponent<ChartPie>();
            chart = c.UIChartPie;
            c.sortingOrder = 103;

            // set default values
            chart.AddValues(new float[] { 110, 100, 10, 200, 200, 700, 70 } );
            chart.SetColor(0, Color.white, Color.black);
            chart.SetColor(1, Color.red, Color.yellow);
            chart.SetColor(2, new Color32(0, 40, 0, 255), new Color32(0, 255, 0, 255));
            chart.Create();

            time = System.Environment.TickCount;
        }
		}//LoadSprite()
		
		/// <summary>
		/// Adds a UI button.		
		/// </summary>
		/// <param name="obj">Parent game object.</param>
		/// <param name="fileName">Resource file name with path, relative to Rersources folder.</param>
		public UIObject Add(UIType type, GameObject obj, string fileName, Sprite spr = null)
		{
			Log.Info("Add: <color=yellow>"+obj.name+" - id:"+obj.GetComponent<GUIText>()+"</color> type:"+type);

			//// Log.GameTimes("_______________-_-_-_-_-_ <color=yellow>"+fileName+" _____ obj: "+obj+"</color>, type: "+type);


			if(images.ContainsKey(obj.GetInstanceID()))
			{
			 	//give warning, then return existing one (ignore new registration)
			 	Log.Debug("This button already registered, ignoring new registration. <color=cyan>" + obj.name+"</color> ");
			 	return images[obj.GetInstanceID()];
			}

			Sprite[] sprList = new Sprite[1];
			if(fileName.Length == 0)
			{

				if(spr == null)
				{
					Log.Debug("This button <color=yellow>"+obj.name+"</color> has no image.");
				}
				else
				{
					Log.Debug("Sprite >>>>>>>>>>>>>>>>> "+spr.name);
					sprList[0] = spr;
				}
			}
			else
			{
				sprList = LoadSprite(fileName);
			}



			UIObject image = null;
			switch(type)
			{
				case UIType.Image:
					Log.Debug("Add UIImage");
					image = new UIImage(obj, sprList);
					break;

				case UIType.Button:
					Log.Debug("Add UIButton");
					image = new UIButton(obj, sprList);
					break;

				case UIType.ToggleButton:
					Log.Debug("Add UIToggleButton");
					image = new UIToggleButton(obj, sprList);
					break;
					
				case UIType.Slider:
					Log.Debug("Add UISlider");
					image = new UISlider(obj, sprList);
					break;

				case UIType.Character:
					Log.Debug("Add UICharacter");
					image = new UICharacter(obj, sprList);
					break;

				case UIType.ChartPie:
					Log.Debug("Add UIChartPie");
					image = new UIChartPie(obj);
					break;

				case UIType.ChartLine:
					Log.Debug("Add UIChartLine");
					image = new UIChartLine(obj);
					break;

				case UIType.Checkbox:
					Log.Debug("Add Checkbox");
					image = new UICheckbox(obj, sprList);
					break;

				default:
					Log.Exception("Invalid UIType to add:" + type);
					break;
			}

			//TODO remove this
			images.Add(obj.GetInstanceID(), image);
			
			//
			//images.Add(""+lastId++, image);
			//Log.Info("Button added:"+obj.name+" image:"+image.Name);

			return image;

		}//Add()