当前位置:网站首页>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
- Database concept and installation
- LV1 tire pressure monitoring
- Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
- A. ABC
- The boss said: whoever wants to use double to define the amount of goods, just pack up and go
- 13. Time conversion function
- Optimization theory: definition of convex function + generalized convex function
- How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
- Global and Chinese markets of advanced X-ray inspection system (Axi) in PCB 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Network communication basic kit -- IPv4 socket structure
From the 18th line to the first line, the new story of the network security industry
Crawler practice website image batch download
Jerry's modification setting status [chapter]
Final consistency of MESI cache in CPU -- why does CPU need cache
3D game modeling is in full swing. Are you still confused about the future?
ZABBIX API pulls the values of all hosts of a monitoring item and saves them in Excel
IPv6 experiment
High level application of SQL statements in MySQL database (I)
Introduction to graphics: graphic painting (I)
随机推荐
1189. Maximum number of "balloons"
Crawler practice website image batch download
STM32 key content
Gee import SHP data - crop image
Global and Chinese markets for electroencephalogram (EEG) devices 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL advanced SQL statement (1)
What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
Résumé: entropie, énergie libre, symétrie et dynamique dans le cerveau
PMP daily three questions (February 14, 2022)
Career development direction
Remote work guide
Database concept and installation
2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
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
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
Problems and solutions of several concurrent scenarios of redis
WordPress collection WordPress hang up collection plug-in
Optimization theory: definition of convex function + generalized convex function
C language black Technology: Archimedes spiral! Novel, interesting, advanced~
Global and Chinese market of contour projectors 2022-2028: Research Report on technology, participants, trends, market size and share