0
0
Unityframework~10 mins

Sprite creation and import in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a Sprite variable in Unity.

Unity
public [1] mySprite;
Drag options to blanks, or click blank then click option'
AMaterial
BSprite
CGameObject
DTexture
Attempts:
3 left
💡 Hint
Common Mistakes
Using Texture instead of Sprite
Using GameObject for sprite variable
2fill in blank
medium

Complete the code to load a sprite named 'hero' from the Resources folder.

Unity
mySprite = Resources.Load<[1]>("hero");
Drag options to blanks, or click blank then click option'
AMaterial
BTexture2D
CGameObject
DSprite
Attempts:
3 left
💡 Hint
Common Mistakes
Using Texture2D instead of Sprite
Using GameObject which loads prefabs
3fill in blank
hard

Fix the error in the code to assign a sprite to a SpriteRenderer component.

Unity
GetComponent<SpriteRenderer>().[1] = mySprite;
Drag options to blanks, or click blank then click option'
Asprite
Btexture
Cmaterial
Dimage
Attempts:
3 left
💡 Hint
Common Mistakes
Using texture instead of sprite
Using image which is for UI components
4fill in blank
hard

Fill both blanks to create a sprite from a texture and assign it to a SpriteRenderer.

Unity
Texture2D tex = Resources.Load<Texture2D>("icon");
Sprite spr = Sprite.Create(tex, new Rect(0, 0, tex.[1], tex.[2]), new Vector2(0.5f, 0.5f));
Drag options to blanks, or click blank then click option'
Awidth
Bheight
Csize
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using size or length which are not Texture2D properties
5fill in blank
hard

Fill all three blanks to load a sprite, assign it to SpriteRenderer, and set its color to red.

Unity
SpriteRenderer sr = GetComponent<SpriteRenderer>();
sr.[1] = Resources.Load<[2]>("enemy");
sr.[3] = Color.red;
Drag options to blanks, or click blank then click option'
Asprite
BSprite
Ccolor
Dmaterial
Attempts:
3 left
💡 Hint
Common Mistakes
Using material instead of color
Loading as Texture2D instead of Sprite