当前位置:网站首页>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);
}
}
边栏推荐
- Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
- LV1 previous life archives
- Idea if a class cannot be found, it will be red
- SQL statement
- Create template profile
- The requests module uses
- 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)
- Kiss number + close contact problem
- Pytoch residual network RESNET
猜你喜欢
16. System and process information
Override and virtual of classes in C #
A brief talk on professional modeler: the prospect and professional development of 3D game modeling industry in China
High level application of SQL statements in MySQL database (I)
C language black Technology: Archimedes spiral! Novel, interesting, advanced~
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Take you to master the formatter of visual studio code
Chain ide -- the infrastructure of the metauniverse
Gee import SHP data - crop image
Example 072 calculation of salary it is known that the base salary of an employee of a company is 500 yuan. The amount of software sold by the employee and the Commission method are as follows: Sales
随机推荐
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
Data collection and summary
Network byte order
在尋求人類智能AI的過程中,Meta將賭注押向了自監督學習
I don't know why it can't run in the project and how to change it
Kiss number + close contact problem
3D game modeling is in full swing. Are you still confused about the future?
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
Global and Chinese market of small batteries 2022-2028: Research Report on technology, participants, trends, market size and share
Keep an IT training diary 054- opening and closing
Question d: Haffman coding
STM32 key content
Pytoch residual network RESNET
17. File i/o buffer
[software implementation series] software implementation interview questions with SQL joint query diagram
中電資訊-信貸業務數字化轉型如何從星空到指尖?
Advanced learning of MySQL -- Application -- index
A. Div. 7
Servlet simple verification code generation
Bugku Zhi, you have to stop him