I’ve loaded a small character image into my assets. And I’ve attached the following script to the main camera, but nothing is appearing when I press play.
using UnityEngine;
using System.Collections;
public class TestSetup : MonoBehaviour {
// Use this for initialization
void Start () {
Sprite backSprite = Resources.Load("WizAnimation1", typeof(Sprite)) as Sprite;
//Create a new gameobject
GameObject obj = new GameObject("Wiz");
//Attach a SpriteRenender to the newly created gameobject
SpriteRenderer rend = obj.AddComponent(typeof(SpriteRenderer)) as SpriteRenderer;
//Assign the sprite to the SpriteRenender
rend.sprite = backSprite;
}
// Update is called once per frame
void Update () {
}
}