当前位置:网站首页>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 :

边栏推荐
- First order traversal / second order traversal determines the approximate shape of the tree
- Explanation of trie tree (dictionary tree)
- Commonly used DOS commands [gradually improved]
- [machine learning] logistic regression code exercise
- 存算一体与存内计算计算杂谈
- 使用cpolar发布树莓派网页(cpolar功能的完善)
- Introduction to translation professional qualification (level) examination
- A structured random inactivation UNET for retinal vascular segmentation
- 基于C语言模拟实现DFA识别字符串
- dataframe.to_sql() 一次性插入过多报错
猜你喜欢
随机推荐
23考研人撑住!考研第一波弃考高峰期已经到来!
How to query express logistics and filter out no information doc No. to delete or copy
dataframe. to_ Sql() inserts too many errors at one time
The biggest upgrade of Bluetooth over the years: Bluetooth Le audio is about to appear in all kinds of digital products
(Video + graphic) introduction to machine learning series - Chapter 3 logical regression
Configuration file settings for remote connection to Windows version server redis
Floweable foundation Chapter 1
基于C语言模拟实现DFA识别字符串
Fluent text editor
md
使用cpolar发布树莓派网页(cpolar功能的完善)
文件上传及拓展
dataframe.to_sql() 一次性插入过多报错
201803-3 Full Score solution of CCF URL mapping
ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
AI is at the forefront | focusing on natural language processing, machine learning and other fields; From Fudan University, Institute of automation, Chinese Academy of Sciences and other teams
【集中培训】HCIP-Cloud Computing 资源交流帖
Floweable advanced
MySQL 错误总结
Rocky基础之编译安装apache








