ResolutionListController.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*===============================================================================
  2. Copyright (C) 2022 Immersal - Part of Hexagon. All Rights Reserved.
  3. This file is part of the Immersal SDK.
  4. The Immersal SDK cannot be copied, distributed, or made available to
  5. third-parties for commercial purposes without written permission of Immersal Ltd.
  6. Contact sdk@immersal.com for licensing requests.
  7. ===============================================================================*/
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using UnityEngine;
  12. using TMPro;
  13. using Immersal.AR;
  14. using Immersal.REST;
  15. namespace Immersal.Samples
  16. {
  17. [RequireComponent(typeof(TMP_Dropdown))]
  18. public class ResolutionListController : MonoBehaviour
  19. {
  20. private TMP_Dropdown m_Dropdown;
  21. private ImmersalSDK m_Sdk;
  22. void Awake()
  23. {
  24. m_Dropdown = GetComponent<TMP_Dropdown>();
  25. m_Dropdown.ClearOptions();
  26. }
  27. void Start()
  28. {
  29. m_Sdk = ImmersalSDK.Instance;
  30. List<string> modes = new List<string>();
  31. foreach (ImmersalSDK.CameraResolution reso in Enum.GetValues(typeof(ImmersalSDK.CameraResolution)))
  32. {
  33. modes.Add(reso.ToString());
  34. }
  35. m_Dropdown.AddOptions(modes);
  36. }
  37. public void OnValueChanged(TMP_Dropdown dropdown)
  38. {
  39. var values = Enum.GetValues(typeof(ImmersalSDK.CameraResolution));
  40. ImmersalSDK.CameraResolution camReso = (ImmersalSDK.CameraResolution)values.GetValue((long)dropdown.value);
  41. #if UNITY_ANDROID
  42. m_Sdk.androidResolution = camReso;
  43. #elif UNITY_IOS
  44. m_Sdk.iOSResolution = camReso;
  45. #endif
  46. }
  47. }
  48. }