using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tto : MonoBehaviour {
public Transform pos;//cube的位置 cube改为空物体
public GameObject[] characterPrefabArray;//不同颜色的cube
public int index = 0;//看的
private GameObject[] goArray;
// Start is called before the first frame update
void Start()
{
if (characterPrefabArray.Length != 0)
{
//实例 隐藏
goArray = new GameObject[characterPrefabArray.Length];
for (int i = 0; i < characterPrefabArray.Length; i++)
{
goArray[i] = Instantiate(characterPrefabArray[i], pos.position, Quaternion .identity );
goArray[i].SetActive(false);
goArray[i].transform.parent = transform;
}
goArray[0].SetActive(true);
}
}
public void PreCharacter()
{
goArray[index].SetActive(false);
index = index == 0 ? (characterPrefabArray.Length - 1) : --index;
goArray[index].SetActive(true);
}
public void NextCharacter()
{
goArray[index].SetActive(false);
index = index == characterPrefabArray.Length - 1 ? 0 : ++index;
goArray[index].SetActive(true);
}
}