I have a 2D player, and it has to be in the Canvas.
Because my NetworkHUD spawns it outside the Canvas, I make my player get inside the canvas and set new position and resize with the following function:
public override void OnStartLocalPlayer()
{
canvas = GameObject.FindWithTag("Canvas");
transform.SetParent(canvas.transform);
Vector3 position = new Vector3(-9.9f, -20.8f, 0);
transform.position = position;
Vector3 scale = new Vector3(1, 1, 1);
transform.localScale = scale;
}
The problem is that it resizes well, but it doesn’t change the position for some reason, and because that, inside the Canvas, it doesn’t show well.
Any solution?