PagedLodUpdateController.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using AIPagedLod;
  5. using System.Xml;
  6. using System;
  7. using System.IO;
  8. public class PagedLodUpdateController : MonoBehaviour
  9. {
  10. public static float mTranslateTreshold = 1.0f;
  11. public static float mRotateTreshold = 1.0f;
  12. public static float mZoomTreshold = 1.0f;
  13. public static bool mIsPagedLodUpdateEnable = true;
  14. void Awake()
  15. {
  16. #if !UNITY_WEBGL && !UNITY_ANDROID
  17. XmlDocument xmlDoc = new XmlDocument();
  18. xmlDoc.Load(Application.streamingAssetsPath + "/PagedLodConfig/Config.xml");
  19. XmlElement cameraConfig = (XmlElement)xmlDoc.DocumentElement.GetElementsByTagName("CameraConfig")[0];
  20. mTranslateTreshold = float.Parse(cameraConfig.GetAttribute("TranslateTreshold"));
  21. mRotateTreshold = float.Parse(cameraConfig.GetAttribute("RotateTreshold"));
  22. mZoomTreshold = float.Parse(cameraConfig.GetAttribute("ZoomTreshold"));
  23. #endif
  24. }
  25. private void Update()
  26. {
  27. bool RotateEnabled = PlayerPrefs.GetInt("CameraRotating") == 0;
  28. bool ZoomEnabled = PlayerPrefs.GetInt("CameraZooming") == 0;
  29. bool TranslateEnable = PlayerPrefs.GetInt("CameraTranslating") == 0;
  30. mIsPagedLodUpdateEnable = RotateEnabled && ZoomEnabled && TranslateEnable;
  31. }
  32. public static bool IsUpdateEnabled()
  33. {
  34. return mIsPagedLodUpdateEnable;
  35. }
  36. }