- Home /
Get sprite to have top-left corner always at top-left of screen
Here is what I have currently to display an image inside of an canvas:
leftImage = GameObject.Find("RawImage");
texture = new Texture2D(2, 2, TextureFormat.RGB24, false);
texture.filterMode = FilterMode.Trilinear;
texture.LoadImage(bytes);
sprite = Sprite.Create(texture, new Rect(0,0,texture.width, texture.height), new Vector2(0.5f,0.5f), 1.0f);
leftImage.GetComponent<UnityEngine.UI.Image> ().sprite = sprite;
However, this always centers it in the middle of the canvas, how can I have it so the picture's top-left is always at the screen's top-left. The canvas it's in is the entire left half of the screen.
Comment