Crosshair not working

#1
I am trying to make a crosshair with a image and a Image UI Component. My code as of now just crashes the game/editor.

Code: Select all

_crosshair = canvas.AddComponent<Image>(); if (_crosshair.GetAlignedRect() != null) { _crosshair.GetAlignedRect().x = 896; _crosshair.GetAlignedRect().y = 476; _crosshair.GetAlignedRect().w = 128; _crosshair.GetAlignedRect().h = 128; } _crosshair.Source = new Resources.ImageSource("Textures/crosshair.dds");
Any help would be appreciated

Who is online

Users browsing this forum: No registered users and 1 guest