SpriteRenderer is not made to be used with the Canvas. You are confusing and misusing the two.
SpriteRenderer
is used for displaying 2D Objects like a 2D animated character or a 2D environment. You can attach Rigidbody2D
and Colliders
to SpriteRenderer
.
Canvas is used for UI display only. It is used for displaying things such as UI texts, buttons, sliders, scrollbars and images. You shouldn't attach Rigidbody2D and Colliders to it or its child objects.
With the explanation above, you should be able to determine which one to use. If you just need to display image under a Canvas, use the Image
, or RawImage
component since they are part of the UI system. This should work but do not make SpriteRenderer
a child of a Canvas. If you have to use SpriteRenderer
, make it its own object or under another object but it should not be under a Canvas. You may find Unity's UI tutorial useful.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…