当前位置:网站首页>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);
}
}
边栏推荐
- MySQL workbench use
- Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.
- Problems and solutions of several concurrent scenarios of redis
- Chapter 3.4: starrocks data import - Flink connector and CDC second level data synchronization
- Bacteriostatic circle scanning correction template
- A. Min Max Swap
- Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
- LV1 tire pressure monitoring
- [untitled] the relationship between the metauniverse and digital collections
- On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
猜你喜欢

C language black Technology: Archimedes spiral! Novel, interesting, advanced~

Small program graduation project based on wechat video broadcast small program graduation project opening report function reference

Node write API

Override and virtual of classes in C #

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

Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends

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

Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.

Advanced learning of MySQL -- Application -- storage engine

Problems and solutions of several concurrent scenarios of redis
随机推荐
Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
The difference between int (1) and int (10)
Problems and solutions of several concurrent scenarios of redis
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
Question d: Haffman coding
Méthode de calcul de la connexion MSSQL de la carte esp32c3
Crawler practice website image batch download
The latest analysis of hoisting machinery command in 2022 and free examination questions of hoisting machinery command
[untitled] the relationship between the metauniverse and digital collections
LV1 tire pressure monitoring
Format character%* s
[untitled]
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
C learning notes: C foundation - Language & characteristics interpretation
A fan summed up so many interview questions for you. There is always one you need!
false sharing
It's corrected. There's one missing < /script >, why doesn't the following template come out?
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
Small program graduation project based on wechat e-book small program graduation project opening report function reference
Node solves cross domain problems