当前位置:网站首页>Unity guidance system. Click the target object and prompt the text to change color to enter the next step
Unity guidance system. Click the target object and prompt the text to change color to enter the next step
2022-07-29 09:23:00 【Starve fish】
using HighlightingSystem;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/*
* The script uses the text color to determine whether the goal is achieved
* Format fixed two lines
*
*/
public class Test : MonoBehaviour
{
[Tooltip(" sound recording ")]
public Button RecodePen;
// Change the rotation state of the switch
public int _SwitchChangerStep;
[Header(" Here are the words that need to change color ")]
public Text text1, text2;
#region Prompt column text list
static string[] t1 = new string[] {
" Click the record button ",
" Click the record button ",
" Click the record button "
};
static string[] t2 = new string[]
{
" Click on A",
" Click on B",
" Click on C"
};
[Header(" The target object that needs to be clicked ")]
public GameObject[] TargetGameobject = new GameObject[t1.Length];
#endregion
public int step;
[Header(" Record button ")]
public Button RecodeSubmit;// At that time, every link of the project should be recorded . You can remove this when making other requirements
private void OnEnable()
{
TargetGameobject[step].SetActive(true);
Debug.Log(string.Format("<color=yellow>{0}</color>", $"{System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName} The script to start ") + "\n This script detects the target ");
RecodeSubmit.onClick.AddListener(() => {
RecodePen.interactable = false;
text1.color = Color.green;
});
}
private void Awake()
{
if (t1.Length != t2.Length) Debug.LogError(" The words fail to correspond one by one !"); // initialization
text1.color = Color.white;
text2.color = Color.white;
}
void Update()
{
if (step < t1.Length)
{
text1.text = t1[step];
text2.text = t2[step];
}
else
{
text1.text = null; text2.text = null;
enabled = false;// The work of this script is over , initialization
}
if (text1.color == Color.green && text2.color == Color.green)
{
text1.color = Color.white; text2.color = Color.white; RecodePen.interactable = true;
step++;
TargetGameobject[step].SetActive(true);
RecodeSubmit.onClick.AddListener(() => {
text1.color = Color.green;
});
}
// Target detection , Discoloration of words
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit raycastHit;
Physics.Raycast(ray, out raycastHit, 2000);
Debug.Log(raycastHit.transform.name);
// At that time, highlight was used to confirm the target object
// If you don't highlight , As the corresponding Targetgameobject[] Go to
if (raycastHit.transform.gameObject.activeInHierarchy && raycastHit.transform.gameObject.GetComponent<Highlighter>().enabled)
{
raycastHit.transform.gameObject.SetActive(false);
text2.color = Color.green;
}
}
}
}
Realization effect :

边栏推荐
- Database system design: partition
- Data type of MySQL
- [unity entry program] collection of common learning websites
- Redis command [gradually improved]
- Floweable foundation Chapter 1
- Gutcloud technology restcloud completed the pre-A round of financing of tens of millions of yuan
- How does alternates achieve high-performance publish and subscribe?
- 基于C语言模拟实现DFA识别字符串
- On the charm of code language
- Implementation of DFA string recognition based on C language simulation
猜你喜欢

Qmainwindow details

Tesseract图文识别--简单

On the charm of code language

ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)

Floweable advanced

不用Swagger,那我用啥?

23考研人撑住!考研第一波弃考高峰期已经到来!

(Video + graphics) introduction to machine learning series - Chapter 1 Introduction

ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)

(Video + graphic) introduction to machine learning series - Chapter 3 logical regression
随机推荐
查看端口占用情况
What are the backup and recovery methods of gbase 8s database
附录2-一些简单的练习
远程连接windows版本服务器redis的配置文件设置
Jetpack Glance? The spring of widgets is coming
Redis command [gradually improved]
乱打日志的男孩运气怎么样我不知道,加班肯定很多
分布式Session共享的4类技术方案,与优劣势比较
MySQL converts some table names to uppercase
What is the key to fast multi tag user profile analysis?
[unity entry program] collection of common learning websites
用户身份标识与账号体系实践
23考研人撑住!考研第一波弃考高峰期已经到来!
Acwing game 59 [End]
C # use database to bind listview control data
redis可视化工具读取数据乱码问题解决
Data representation and calculation (base)
LeetCode刷题(6)
四元数与其在Unity中的简单应用
A structured random inactivation UNET for retinal vascular segmentation