当前位置:网站首页>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);
}
}
边栏推荐
- Leetcode 110 balanced binary tree
- The reasons why QT fails to connect to the database and common solutions
- Create template profile
- Network communication basic kit -- IPv4 socket structure
- Idea if a class cannot be found, it will be red
- The difference between lambda expressions and anonymous inner classes
- Amélioration de l'efficacité de la requête 10 fois! 3 solutions d'optimisation pour résoudre le problème de pagination profonde MySQL
- Question d: Haffman coding
- Life cycle of instance variables, static variables and local variables
- [untitled]
猜你喜欢

High level application of SQL statements in MySQL database (I)

Unspeakable Prometheus monitoring practice

JVM performance tuning and practical basic theory - medium

The automatic control system of pump station has powerful functions and diverse application scenarios

Mysql-15 aggregate function

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

Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference

Talking about custom conditions and handling errors in MySQL Foundation

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.

Basic editing specifications and variables of shell script
随机推荐
Summarize the past to motivate yourself to move on
What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
Sword finger offer 20 String representing numeric value
Comment la transformation numérique du crédit d'information de la Chine passe - t - elle du ciel au bout des doigts?
Will the memory of ParticleSystem be affected by maxparticles
Key knowledge of embedded driver
false sharing
String & memory function (detailed explanation)
Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference
Write the first CUDA program
Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
Create template profile
Override and virtual of classes in C #
Chain ide -- the infrastructure of the metauniverse
Global and Chinese market of box seals 2022-2028: Research Report on technology, participants, trends, market size and share
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
Network communication basic kit -- IPv4 socket structure
Why can't it run (unresolved)
Talking about custom conditions and handling errors in MySQL Foundation
Keep an IT training diary 054- opening and closing