示例#1
0
 public UIImage(string name, Rectangle bounds, UIAlignment boundsAlign, UIAlignment alignment, flags flags, string imageName, string targetName = null) : base(name, bounds, boundsAlign, alignment, flags)
 {
     spriteRenderer        = SpriteRenderer.MakeSpriteRenderer(name, imageName, targetName);
     spriteRenderer.Name   = name;
     spriteRenderer.sprite = Resources.LoadAsset(new Sprite().GetType(), imageName, SceneManager.activeScene) as Sprite;
     spriteRenderer.sprite.DestinationRect = new Rectangle((int)origin.X, (int)origin.Y, this.bounds.Width, this.bounds.Height);
 }
示例#2
0
        public UIObject(string name, UIAlignment boundsAlign, UIAlignment alignment, flags flag)
        {
            //default values (this will be overwritten in derived classes)
            bounds       = new Rectangle(0, 0, 0, 0);
            childObjects = new List <UIObject>();
            this.Name    = name;
            this.flag    = flag;

            origin = alignment.GetAlignment(this, this);
        }
示例#3
0
        public UIObject(string name, Rectangle bounds, UIAlignment boundsAlign, UIAlignment alignment, flags flag)
        {
            childObjects = new List <UIObject>();
            this.Name    = name;
            this.bounds  = bounds;
            this.flag    = flag;

            Vector2 boundsAlignment = boundsAlign.GetAlignment(this, parent);

            this.bounds.X = (int)boundsAlignment.X;
            this.bounds.Y = (int)boundsAlignment.Y;

            origin = alignment.GetAlignment(this, this);
        }
示例#4
0
        public UIText(string name, UIAlignment boundsAlign, UIAlignment alignment, flags flag, string fontName, string text, int fontSize, string targetName = null) : base(name, boundsAlign, alignment, flag)
        {
            textRenderer      = TextRenderer.MakeTextRenderer(name, fontName, targetName);
            textRenderer.Size = fontSize;
            textRenderer.Text = text;
            //textRenderer.Font = Resources.LoadAsset(new Font().GetType(), fontName, SceneManager.activeScene) as Font;

            //get the width and height of the string being drawn
            bounds.Width  = (int)((float)textRenderer.Font.GetFont(fontSize).MeasureString(text).X *(float)fontSize / (float)textRenderer.Font.GetSize(fontSize));
            bounds.Height = (int)((float)textRenderer.Font.GetFont(fontSize).MeasureString(text).Y *(float)fontSize / (float)textRenderer.Font.GetSize(fontSize));

            Vector2 boundsAlignment = boundsAlign.GetAlignment(this, parent);

            bounds.X = (int)boundsAlignment.X;
            bounds.Y = (int)boundsAlignment.Y;

            textRenderer.Position = new Vector2(bounds.X, bounds.Y);
        }