![]() The overall perception of rounding in the system is shaped by both software rounding, controlled by the OS, and hardware rounding, controlled by OEM partners. using System.As part of Windows 11’s unique new design language, rounded corners play an integral role in the look and feel of the UI. If you want unity to do some antialiasing, you can increase the resolution of the raw image and remove the call to display.SetNativeSize() But then you will need to set the actual size of the rectangle using its transform component. I just attached the component to the rawimage and set the Display property to itself This is default setup you get with Game Object -> UI -> Raw Image When I take this code and put it on a RawImage in a UICanvas it looks fine. It removed the black color but made it more jagged. With return Color32.Lerp(color, Color.clear, shadowIntensity) īut that didn't smooth it with a transparent color. I tried fixing the black jagged edge by replacing the return Color32.Lerp(color, Color.black, shadowIntensity) Return Color32.Lerp(color, Color.black, shadowIntensity) Private static Color32 DarkenColor(Color32 color, float shadowIntensity) Return DarkenColor(initialColor, ((shadowDiff * mod) + finalShadowIntensity)) If (distance > borderRadius + borderThickness + 1)Įlse if (distance > borderRadius - borderShadow + 1)įloat mod = (distance - (borderRadius - borderShadow)) / borderShadow įloat shadowDiff = initialShadowIntensity - finalShadowIntensity Origin = new Vector2(x, height - (borderRadius + borderThickness)) įloat distance = Vector2.Distance(point, origin) Origin = new Vector2(width - (borderRadius + borderThickness), y) Origin = new Vector2(width - (borderRadius + borderThickness), height - (borderRadius + borderThickness)) If (y height - (borderRadius + borderThickness)) Origin = new Vector2(borderRadius + borderThickness, y) Įlse if (x > width - (borderRadius + borderThickness)) Origin = new Vector2(borderRadius + borderThickness, height - (borderRadius + borderThickness)) If (x height - (borderRadius + borderThickness)) If (internalRectangle.Contains(point)) return initialColor Rect internalRectangle = new Rect((borderThickness + borderRadius), (borderThickness + borderRadius), width - 2 * (borderThickness + borderRadius), height - 2 * (borderThickness + borderRadius)) If (borderShadow > borderRadius) throw new ArgumentException("Border shadow must be lesser in magnitude than the border radius (suggeted: shadow borderColors, float initialShadowIntensity, float finalShadowIntensity) If (borderRadius height / 2 || borderThickness + borderRadius > width / 2) throw new ArgumentException("Border will be too thick and/or rounded to fit on the texture.") If (borderColors = null || borderColors.Count = 0) throw new ArgumentException("Must define at least one border color (up to three).") If (backgroundColors = null || backgroundColors.Count = 0) throw new ArgumentException("Must define at least one background color (up to four).") Public static Texture2D CreateRoundedRectangleTexture(int width, int height, int borderThickness, int borderRadius, int borderShadow, List backgroundColors, List borderColors, float initialShadowIntensity, float finalShadowIntensity) InitialShadowIntensity, finalShadowIntensity) Public float initialShadowIntensity = 5f īackgroundColors.Add(new Color32(171, 0, 0, 255)) īackgroundColors.Add(new Color32(9, 48, 173, 255)) īorderColors.Add(new Color32(111, 8, 99, 255)) īorderColors.Add(new Color32(171, 4, 161, 255)) ĬreateRoundedRectangleTexture(width, height, borderThickness,īorderRadius, borderShadow, backgroundColors, borderColors, Public int borderThickness = 1 //Cannot be backgroundColors = new List() I ported it into Unity but the Edge is jaggy.īelow is the ported code: public int width = 256 This post did that but with XNA instead of Unity. My goal is to create this rounded Texture with the Texture2D class by setting the pixels with the SetPixels32 function. I am trying to draw rounded rectangles which can be used as a Texture for any UI component.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |