Hi!
I’ve been using XNA for so long that I don’t really get how to do simple stuff on unity,
what I’m trying to do is create a class “Card” and that card a Sprite property,
then be able to create a new Card and instantiate it on the scene.
So I tried something like this:
using UnityEngine;
using System.Collections;
public class Main : MonoBehaviour {
// Use this for initialization
void Start () {
Carta back = new Carta();
back.imagen = Resources.Load ("backcard", Sprite);
Instantiate(back, new Vector3(0, 0, 0), new Quaternion());
}
// Update is called once per frame
void Update () {
}
}
public class Carta{
public Sprite imagen;
public string nombre;
}
But it does nothing (the main.cs script is attached to the main camera).
Obviously I don’t know what I’m doing… I tried with public class Carta : Object and it’s the same.
Could someone tell me how to do something like this?
The idea is to be able to create a lot of different Cards (class Carta) programmatically and instantiate them when needed.
(Game is 2D).
Hope someone can help me, thanks