Advertisement
KorolevDmitry123

Untitled

Jul 21st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Lod : MonoBehaviour {
  5. public GameObject[] models;
  6. public int[] distance;
  7. private float dist;
  8. private bool mainCamActive;
  9. private bool gCamActive;
  10. public GameObject mainCamera;
  11. public GameObject cameraG;
  12. void Start()
  13. {
  14. models[0].gameObject.SetActive(false);
  15. models[1].gameObject.SetActive(false);
  16. }
  17. void Update()
  18. {
  19. mainCamActive = mainCamera.activeSelf;
  20. gCamActive = cameraG.activeSelf;
  21. if (mainCamActive == true)
  22. {
  23. dist = Vector3.Distance(mainCamera.transform.position, transform.position);
  24. }
  25. if (gCamActive == true)
  26. {
  27. dist = Vector3.Distance(cameraG.transform.position, transform.position);
  28. }
  29. if (dist <= distance[0])
  30. {
  31. models[0].gameObject.SetActive(true);
  32. models[1].gameObject.SetActive(false);
  33. }
  34. if (dist > distance[0] && dist <= distance[1])
  35. {
  36. models[0].gameObject.SetActive(false);
  37. models[1].gameObject.SetActive(true);
  38. }
  39. if (dist > distance[1])
  40. {
  41. models[0].gameObject.SetActive(false);
  42. models[1].gameObject.SetActive(false);
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement