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

边栏推荐
- [Bert multi label text classification practice] I - overview of practical projects
- [unity entry program] C # and unity - understand classes and objects
- 机器学习之分类模型评估指标及sklearn代码实现
- Flutter文本编辑器
- Redis command [gradually improved]
- 【Unity入门计划】常用学习网址收藏
- (Video + graphics) introduction to machine learning series - Chapter 1 Introduction
- MySQL 错误总结
- Tesseract text recognition -- simple
- 高智伟:数据管理赋能交通行业数字化转型
猜你喜欢

STM32 application development practice tutorial: design and implementation of controllable LED water lamp

First order traversal / second order traversal determines the approximate shape of the tree

【机器学习】朴素贝叶斯代码练习

Sublime text create page

Introduction to translation professional qualification (level) examination

【Unity入门计划】C#与Unity-了解类和对象

用户身份标识与账号体系实践

Use cpolar to publish raspberry pie web pages (improvement of cpolar tunnel)

Asp graduation project - based on C # +asp Net+sqlserver laboratory reservation system design and Implementation (graduation thesis + program source code) - Laboratory Reservation System

乱打日志的男孩运气怎么样我不知道,加班肯定很多
随机推荐
【Unity入门计划】常用学习网址收藏
基于ArkUI eTS开发的坚果新闻(NutNews)
User identity identification and account system practice
1.2.24 fastjson deserialization templatesimpl uses chain analysis (very detailed)
LeetCode刷题(6)
Flowable 高级篇
当 update 修改数据与原数据相同时会被更新吗?
Unity 引导系统.点击目标物体后提示文字变色进入下一步
Flowable 基础篇1
C# 使用RestSharp库实现POST请求
md
网络原理笔记(五层网络)
Evaluation index of machine learning classification model and implementation of sklearn code
On contract testing
Safety is no longer the only selling point. Test drive "slash youth" Volvo C40
ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
Asp graduation project - based on C # +asp Net+sqlserver laboratory reservation system design and Implementation (graduation thesis + program source code) - Laboratory Reservation System
[unity entry program] C # and unity - understand classes and objects
[Bert multi label text classification practice] I - overview of practical projects
使用cpolar发布树莓派网页(cpolar隧道的完善)