您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
51 行
1.3 KiB
51 行
1.3 KiB
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UIWidgetsGallery.gallery
|
|
{
|
|
public class heroItem : MonoBehaviour
|
|
{
|
|
private List<GameObject> items = new List<GameObject>();
|
|
|
|
private static int _previousHeroType = 0;
|
|
public static int heroType = 0;
|
|
|
|
void Start()
|
|
{
|
|
var cube = transform.Find("Cube").gameObject;
|
|
var sphere = transform.Find("Sphere").gameObject;
|
|
var cylinder = transform.Find("Cylinder").gameObject;
|
|
var capsule = transform.Find("Capsule").gameObject;
|
|
|
|
items.Add(cube);
|
|
items.Add(sphere);
|
|
items.Add(capsule);
|
|
items.Add(cylinder);
|
|
|
|
UpdateItem();
|
|
}
|
|
|
|
void UpdateItem()
|
|
{
|
|
for (var i = 0; i < items.Count; i++)
|
|
{
|
|
items[i].SetActive(i == heroType);
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (heroType != _previousHeroType)
|
|
{
|
|
_previousHeroType = heroType;
|
|
UpdateItem();
|
|
}
|
|
|
|
transform.Rotate(
|
|
0 * Time.deltaTime,
|
|
60f * Time.deltaTime,
|
|
0 * Time.deltaTime
|
|
);
|
|
}
|
|
}
|
|
}
|