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

边栏推荐
- 云原生管理实践:业务引领的DevOps持续交付体系
- How to change MySQL into Chinese
- 【机器学习】朴素贝叶斯代码练习
- Asp graduation project - based on C # +asp Design and implementation of enterprise investment value analysis system based on. Net + sqlserver (graduation thesis + program source code) -- enterprise in
- 简述堆和栈的区别
- Flowable 高级篇
- VS2015采用loadlibrary方式调用dll库
- Fluent text editor
- Travel notes in 2022 (ongoing)
- On contract testing
猜你喜欢
![[machine learning] logistic regression code exercise](/img/dc/203f240e2eb213dbd6173d17e47ec6.jpg)
[machine learning] logistic regression code exercise

Solve the problem of reading data garbled by redis visualization tool

LeetCode刷题(6)

文件重命名后,怎样将新旧文件名及所在位置导出到excel

数仓项目踩坑记录与解决方法总结

Floweable foundation Chapter 1

Flowable 基础篇2

Use cpolar to publish raspberry pie web pages (improvement of cpolar function)
数据表示与计算(进制)
网络原理笔记(五层网络)
随机推荐
Summary of some experiences in the process of R & D platform splitting
No swagger, what do I use?
What is the key to fast multi tag user profile analysis?
How does alternates achieve high-performance publish and subscribe?
Unity Xchart3.0基本用法快速上手
36. JS animation
Tesseract text recognition -- simple
dataframe. to_ Sql() inserts too many errors at one time
基于C语言模拟实现DFA识别字符串
Qmainwindow details
Floweable advanced
Vs2015 uses loadlibrary to call DLL library
工业测控设备内生信息安全技术研究综述
存算一体与存内计算计算杂谈
如何介绍自己的项目经验?
Use cpolar to publish raspberry pie web pages (improvement of cpolar function)
36. JS动画
Commonly used DOS commands [gradually improved]
File upload and expansion
多标签用户画像分析跑得快的关键在哪里?