2D Sprite / GameObject Character Creation C#
Hi, I have just started programming in 2D and I am currently making a character selector in 2D. I have it working in 3D when I use cubes for objects but in 2d I'm trying to use sprites as the characters and nothing seems to appear. I'm also wondering that when programming in 2D do you replace "GameObject" or "gameObject" with "Sprite"? Here is the code with what I have done: using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic;
public class CharacterCreation : MonoBehaviour {
public GameObject GameDataCharacter;
private List<GameObject> models;
private int selectionIndex = 0;
// Use this for initialization
private void Start () {
models = new List<GameObject>();
foreach (Transform characters in transform)
{
models.Add(characters.gameObject);
characters.gameObject.SetActive(false);
}
models[selectionIndex].SetActive(true);
}
// Update is called once per frame
void Update () {
}
public void Select(int index)
{
if (index == selectionIndex)
return;
if (index < 0 || index >= models.Count)
return;
models[selectionIndex].SetActive(false);
selectionIndex = index;
models[selectionIndex].SetActive(true);
}
}
Thanks for all the help, and if anyone could possibly send me in the right direction to a good 2D tutorial, it would be greatly appreciated! Thanks!
Not sure on the answer to your question but this might help you:
https://www.youtube.com/watch?v=1EJOYWBcrzQ
https://www.youtube.com/channel/UCyBsvsU7uiur$$anonymous$$iBZIYXvnyg
Your answer