using System.Collections; using System.Collections.Generic; using UnityEngine; public class HandFontSelfCtr : MonoBehaviour { //控制碰撞体显示 bool oneIsRun = false; float oneWaitTime = 1f; float oneRunTime = 0; //显示简体字计时相关 bool twoIsRun = false; float twoWaitTime = 3f; float twoRunTime = 0; //整个隐藏计时相关 bool threeIsRun = false; float threeWaitTime = 2f; float threeRunTime = 0; BoxCollider boxCollider; Animator animator; // Start is called before the first frame update void Start() { animator = GetComponent(); boxCollider = GetComponent(); if (boxCollider != null) boxCollider.enabled = false; } // Update is called once per frame void Update() { if (oneIsRun) { oneRunTime += Time.deltaTime; if (oneRunTime >= oneWaitTime) { oneIsRun = false; oneRunTime = 0; if (boxCollider != null) boxCollider.enabled = true; } } if (twoIsRun) { twoRunTime += Time.deltaTime; if (twoRunTime >= twoWaitTime) { if (boxCollider != null) boxCollider.enabled = false; twoIsRun = false; twoRunTime = 0; animator.Play("Translate"); threeIsRun = true; } } if (threeIsRun) { threeRunTime += Time.deltaTime; if (threeRunTime >= threeWaitTime) { threeIsRun = false; threeRunTime = 0; //this.gameObject.SetActive(false); } } } private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R") { if (boxCollider != null) boxCollider.enabled = false; twoIsRun = false; twoRunTime = 0; animator.Play("Translate"); threeIsRun = true; } } public void PlayShowJGWFont() { //this.transform.LookAt(Camera.main.transform); //this.transform.localPosition = new Vector3(this.transform.localPosition.x, this.transform.localPosition.y+(-90), this.transform.localPosition.z); oneIsRun = true; twoIsRun = true; if (animator != null) animator.Play("Open"); } }