using System.Collections; using System.Collections.Generic; using UnityEngine; public class MySplitTerrainTile : MonoBehaviour { //Terrain tm; //TerrainCollider tc; GameObject player; float curTime = 0; public float refreshTime = 2.0f; public bool isShow = false; // Start is called before the first frame update void Start() { //tm = this.GetComponent(); //tc = this.GetComponent(); } // Update is called once per frame void Update() { curTime += Time.deltaTime; if(curTime - refreshTime > 0) { curTime -= refreshTime; } else { return; } if (!HeroPlayerController.Instance.m_Hero) { return; } player = HeroPlayerController.Instance.m_Hero.gameObject; if (Vector3.Distance(player.transform.position, this.transform.position) < 65) { ShowOrHide(true); } else { ShowOrHide(false); } } public void ShowOrHide(bool b) { isShow = b; for (int i = 0; i < transform.childCount; ++i) { Transform subTsfm = transform.GetChild(i); subTsfm.gameObject.SetActive(b); } } //private void OnTriggerEnter(Collider other) //{ // if (other.gameObject.layer != LayerMask.NameToLayer("Player")) // { // return; // } //} //private void OnTriggerExit(Collider other) //{ // if (other.gameObject.layer != LayerMask.NameToLayer("Player")) // { // return; // } //} }