/// <summary>
        /// Register events to a ui button
        /// A button has 3 valid functions:
        /// Click, Release adn Over. The rest will not be processed.
        /// Return true if registration was successfull
        /// </summary>
        public bool Register(UIEvent uiEvent, UIButtonFunction function)
        {
            switch(uiEvent)
            {
                case UIEvent.Click:
                    onClick += function;
                    break;

                case UIEvent.Pressed:
                    onPush += function;
                    break;

                case UIEvent.Release:
                    onRelease += function;
                    break;

                case UIEvent.Over:
                    onOver += function;
                    break;

                case UIEvent.OverExit:
                    onOverExit += function;
                    break;

                default:
                    Log.Error("Invalid event type for Button:"+uiEvent);
                    return false;
            }

            return true;
        }
        //------------------------------------------------------------------------------
        public UIButton(GameObject obj, Sprite[] sprites)
            : base(obj, sprites)
        {
            //Log.Debug("UIButton "+obj.name);

            this.type = UIType.Button;
            this.onClick = onClick;
            this.onRelease = onRelease;
            this.onOver = onOver;

            textColors = new Color[5];

            if(sprites != null)
            {
                this.image = gameObject.GetComponent<UnityEngine.UI.Image>();
                if (this.image == null)
                {
                    this.image = gameObject.AddComponent<UnityEngine.UI.Image>();
                }
                //if(this.render == null)
                //	Log.Error("Button must have a SpriteRenderer! Button:"+obj.name);

            }
        }