当前位置:网站首页>Unity controls the selection of the previous and next characters
Unity controls the selection of the previous and next characters
2022-07-04 02:27:00 【LiPing122335】

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tto : MonoBehaviour {
public Transform pos;//cube The location of cube Change to empty object
public GameObject[] characterPrefabArray;// Different colors of cube
public int index = 0;// See
private GameObject[] goArray;
// Start is called before the first frame update
void Start()
{
if (characterPrefabArray.Length != 0)
{
// example hide
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);
}
}
边栏推荐
- Question d: Haffman coding
- Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
- What are the main investment products of bond funds and what are they
- Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
- VRRP+BFD
- Data collection and summary
- [software implementation series] software implementation interview questions with SQL joint query diagram
- Servlet simple verification code generation
- Network byte order
- After listening to the system clear message notification, Jerry informed the device side to delete the message [article]
猜你喜欢

Life cycle of instance variables, static variables and local variables

Applet graduation project based on wechat selection voting applet graduation project opening report function reference

MySQL advanced SQL statement (1)
![Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine](/img/3a/cf6285ae1c01bda42874eeca9fe5b1.jpg)
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine

Node solves cross domain problems

Gee import SHP data - crop image

Small program graduation project based on wechat reservation small program graduation project opening report reference

Idea if a class cannot be found, it will be red

Network communication basic kit -- IPv4 socket structure

16. System and process information
随机推荐
求esp32C3板子連接mssql方法
MySQL advanced SQL statement (1)
SQL statement
[untitled]
The contact data on Jerry's management device supports reading and updating operations [articles]
Design and implementation of redis 7.0 multi part AOF
[Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)
Keep an IT training diary 055- moral bitch
查詢效率提昇10倍!3種優化方案,幫你解决MySQL深分頁問題
12. Gettimeofday() and time()
Setting function of Jerry's watch management device [chapter]
Crawler practice website image batch download
LV1 Roche limit
String & memory function (detailed explanation)
中電資訊-信貸業務數字化轉型如何從星空到指尖?
[Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)
Bacteriostatic circle scanning correction template
長文綜述:大腦中的熵、自由能、對稱性和動力學
Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
Advanced learning of MySQL -- Application -- storage engine