当前位置:网站首页>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);
}
}
边栏推荐
- Comment la transformation numérique du crédit d'information de la Chine passe - t - elle du ciel au bout des doigts?
- The boss said: whoever wants to use double to define the amount of goods, just pack up and go
- C # learning notes: structure of CS documents
- After listening to the system clear message notification, Jerry informed the device side to delete the message [article]
- Sword finger offer 20 String representing numeric value
- Optimization theory: definition of convex function + generalized convex function
- Yyds dry goods inventory override and virtual of classes in C
- 2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
- Will the memory of ParticleSystem be affected by maxparticles
- Keep an IT training diary 054- opening and closing
猜你喜欢

Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)

Comment la transformation numérique du crédit d'information de la Chine passe - t - elle du ciel au bout des doigts?

The reasons why QT fails to connect to the database and common solutions

Node write API

When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview

The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult

From the 18th line to the first line, the new story of the network security industry

ZABBIX API pulls the values of all hosts of a monitoring item and saves them in Excel

Ai aide à la recherche de plagiat dans le design artistique! L'équipe du professeur Liu Fang a été embauchée par ACM mm, une conférence multimédia de haut niveau.

長文綜述:大腦中的熵、自由能、對稱性和動力學
随机推荐
Format character%* s
[untitled] the relationship between the metauniverse and digital collections
STM32 key content
Keep an IT training diary 055- moral bitch
The difference between int (1) and int (10)
Johnson–Lindenstrauss Lemma
求esp32C3板子連接mssql方法
Data collection and summary
Setting function of Jerry's watch management device [chapter]
ZABBIX API batch delete a template of the host
VRRP+BFD
Description of setting items of Jerry [chapter]
C learning notes: C foundation - Language & characteristics interpretation
Network byte order
Properties of binary trees (numerical aspects)
Reading notes - learn to write: what is writing?
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
Summarize the past to motivate yourself to move on
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge