Home c# Problem with Sprite Renderer in Unity 2D

Problem with Sprite Renderer in Unity 2D




I created an Hero object and shoved Sprite to it, but in this line of the Sprite = getComponentinchildren & lt; Spriterender & gt; (); it appeals to the Sprite Renderer inside Hero, not to sprite inside the HERO object. How to fix it? (I’m new to unity)

Answer 1, Authority 100%

sprite = getComponent & lt; spriterender & gt; (). Sprite;

see Documentation: https://docs.unity3d.com/scriptreference/spriterender.html

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions