Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Lod : MonoBehaviour {
- public GameObject[] models;
- public int[] distance;
- private float dist;
- private bool mainCamActive;
- private bool gCamActive;
- public GameObject mainCamera;
- public GameObject cameraG;
- void Start()
- {
- models[0].gameObject.SetActive(false);
- models[1].gameObject.SetActive(false);
- }
- void Update()
- {
- mainCamActive = mainCamera.activeSelf;
- gCamActive = cameraG.activeSelf;
- if (mainCamActive == true)
- {
- dist = Vector3.Distance(mainCamera.transform.position, transform.position);
- }
- if (gCamActive == true)
- {
- dist = Vector3.Distance(cameraG.transform.position, transform.position);
- }
- if (dist <= distance[0])
- {
- models[0].gameObject.SetActive(true);
- models[1].gameObject.SetActive(false);
- }
- if (dist > distance[0] && dist <= distance[1])
- {
- models[0].gameObject.SetActive(false);
- models[1].gameObject.SetActive(true);
- }
- if (dist > distance[1])
- {
- models[0].gameObject.SetActive(false);
- models[1].gameObject.SetActive(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement