1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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<Terrain>();
- //tc = this.GetComponent<TerrainCollider>();
- }
- // 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;
- // }
- //}
- }
|