From c1c11265a52eb964c94debead3c11a897c61a6c0 Mon Sep 17 00:00:00 2001 From: Jadis0x <49281043+jadis0x@users.noreply.github.com> Date: Fri, 10 Mar 2023 12:11:35 +0300 Subject: [PATCH] Add: GetCircularTexture function In this code, a circular crosshair texture is generated using a nested loop to iterate over each pixel of the texture. The distance between each pixel and the center of the texture is calculated using the Vector2.Distance function. If this distance is less than or equal to the radius of the circle, the pixel is set to white, otherwise it is set to transparent. The resulting texture is then drawn on the screen using the GUI.DrawTexture function. --- DevourClient/Helpers/GUIHelper.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/DevourClient/Helpers/GUIHelper.cs b/DevourClient/Helpers/GUIHelper.cs index ff2f1d8..8d4e1aa 100644 --- a/DevourClient/Helpers/GUIHelper.cs +++ b/DevourClient/Helpers/GUIHelper.cs @@ -49,5 +49,28 @@ namespace DevourClient.Helpers result.Apply(); return result; } + + public static Texture2D GetCircularTexture(int width, int height) + { + Texture2D texture = new Texture2D(width, height); + for (int x = 0; x < texture.width; x++) + { + for (int y = 0; y < texture.height; y++) + { + if (Vector2.Distance(new Vector2(x, y), new Vector2(texture.width / 2, texture.height / 2)) <= texture.width / 2) + { + texture.SetPixel(x, y, Color.white); + } + else + { + texture.SetPixel(x, y, Color.clear); + } + } + } + + texture.Apply(); + + return texture; + } } }