赞
踩
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class LODAndOcclusionController : MonoBehaviour {
-
- public GameObject sphere;
- // Use this for initialization
- void Start () {
-
- }
-
- // Update is called once per frame
- void Update () {
- if (Vector3.Distance (this.transform.position, sphere.transform.position) > 5f) {
- sphere.GetComponent ().enabled = false;
- } else {
- sphere.GetComponent ().enabled = true;
- }
- }
- }

- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class OcclusionController : MonoBehaviour {
- private GameObject[] occlusionGameObjects;
- // Use this for initialization
- void Start () {
- occlusionGameObjects = GameObject.FindGameObjectsWithTag ("Occlusion");
- }
-
- // Update is called once per frame
- void Update () {
- foreach (GameObject item in occlusionGameObjects) {
- Ray ray = new Ray (this.transform.position, (item.transform.position - transform.position));
- RaycastHit hit;
- Debug.DrawLine (transform.position, item.transform.position - transform.position, Color.red);
- if (Physics.Raycast (ray, out hit)) {
- if (hit.transform.gameObject == item) {
- item.GetComponent ().enabled = true;
- } else {
- item.GetComponent ().enabled = false;
- }
- }
- }
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。