NRProjectConfigEditor.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. using UnityEngine;
  10. using UnityEditor;
  11. using NRKernal;
  12. [CustomEditor(typeof(NRProjectConfig))]
  13. public class NRProjectConfigEditor : Editor
  14. {
  15. override public void OnInspectorGUI()
  16. {
  17. NRProjectConfig projectConfig = (NRProjectConfig)target;
  18. DrawUniqueProjectConfig(projectConfig);
  19. EditorGUILayout.Space();
  20. }
  21. public static void DrawUniqueProjectConfig(NRProjectConfig projectConfig)
  22. {
  23. //Target Devices properties
  24. EditorGUILayout.LabelField("Target Devices", EditorStyles.boldLabel);
  25. EditorGUILayout.BeginVertical(EditorStyles.helpBox);
  26. bool modify = false;
  27. foreach (NRDeviceType deviceType in System.Enum.GetValues(typeof(NRDeviceType)))
  28. {
  29. bool curSupport = projectConfig.targetDeviceTypes.Contains(deviceType);
  30. bool newSupport = curSupport;
  31. NREditorUtility.BoolField(projectConfig, ObjectNames.NicifyVariableName(deviceType.ToString()), ref newSupport, ref modify);
  32. if (newSupport && !curSupport)
  33. {
  34. projectConfig.targetDeviceTypes.Add(deviceType);
  35. }
  36. else if (curSupport && !newSupport)
  37. {
  38. projectConfig.targetDeviceTypes.Remove(deviceType);
  39. }
  40. }
  41. EditorGUILayout.EndVertical();
  42. if (modify)
  43. {
  44. NRProjectConfigHelper.CommitProjectConfig(projectConfig);
  45. }
  46. }
  47. }