当前位置:网站首页>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);
}
}
边栏推荐
- A fan summed up so many interview questions for you. There is always one you need!
- What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
- Node write API
- Hunan University | robust Multi-Agent Reinforcement Learning in noisy environment
- Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
- Johnson–Lindenstrauss Lemma
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- Global and Chinese market of thin film deposition systems 2022-2028: Research Report on technology, participants, trends, market size and share
- Small program graduation project based on wechat reservation small program graduation project opening report reference
- Node solves cross domain problems
猜你喜欢
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Life cycle of instance variables, static variables and local variables
ZABBIX API pulls the values of all hosts of a monitoring item and saves them in Excel
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
Small program graduation project based on wechat e-book small program graduation project opening report function reference
1189. Maximum number of "balloons"
Small program graduation project based on wechat examination small program graduation project opening report function reference
What are the conditions for the opening of Tiktok live broadcast preview?
Will the memory of ParticleSystem be affected by maxparticles
随机推荐
Crawler practice website image batch download
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Setting function of Jerry's watch management device [chapter]
Why can't it run (unresolved)
PMP daily three questions (February 14, 2022)
Containerization technology stack
ZABBIX API batch delete a template of the host
What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
長文綜述:大腦中的熵、自由能、對稱性和動力學
The contact data on Jerry's management device supports reading and updating operations [articles]
String & memory function (detailed explanation)
Libcblas appears when installing opencv import CV2 so. 3:cannot open shared object file:NO such file or directory
Career development direction
15. System limitations and options
Jerry's update contact [article]
Buuctf QR code
Servlet simple verification code generation
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.
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
From the 18th line to the first line, the new story of the network security industry