Basic Drawing Operations


I recently started to migrate some previous sourcecode from Unity to Stride. It´s a basic user interface for a realtime strategy game and meanwhile I´m facing some problems during the migration. Maybe someone of you people here could help me with it.

The problem:
I used some basic drawing operations in Unity to show the mouse selection area to the player. I also put some rectangles around the selected buildings and units. But somehow I was not able to migrate this simple task to Stride/Xenko.

Here are some code snippets from Unity (I´ve found them originally in some YouTube tutorials):

m_SelectionTexture = new Texture2D(1, 1);
m_SelectionTexture.SetPixel(0, 0, Color.white);

protected void DrawScreenRect(Rect rect, Color color)
   GUI.color = color;
   GUI.DrawTexture(rect, m_SelectionTexture);
   GUI.color = Color.white;

protected void DrawScreenRectBorder(Rect rect, float thickness, Color color)
  this.DrawScreenRect(new Rect(rect.xMin, rect.yMin, rect.width, thickness), color);
  this.DrawScreenRect(new Rect(rect.xMin, rect.yMin, thickness, rect.height), color);
  this.DrawScreenRect(new Rect(rect.xMax - thickness, rect.yMin, thickness, rect.height), color);
  this.DrawScreenRect(new Rect(rect.xMin, rect.yMax - thickness, rect.width, thickness), color);

So maybe Stride/Xenko is not working that way. But is there an alternative way to get similar results?

I would be grateful for suggestions and advice. :slight_smile:

Best regards,

@Saber I think this is called sprite in Stride. Have a look at the graphics tests on GitHub, there are several examples of that…

Thank you.

I´ve already had a look for sprites, but I can´t find any good solution for my problem in this topic, too. Since I´ve spend some weeks on the Stride engine now, I´ve made a switch to GODOT last weekend. I really like the Stride approach, but the documentation is not good at all unfortunetelly.