NRSessionConfigEditor.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. namespace NRKernal
  12. {
  13. [CustomEditor(typeof(NRSessionConfig))]
  14. public class NRSessionConfigEditor : Editor
  15. {
  16. SerializedProperty PlaneFindingMode;
  17. SerializedProperty ImageTrackingMode;
  18. SerializedProperty TrackingImageDatabase;
  19. SerializedProperty EnableNotification;
  20. SerializedProperty ForceKillWhileGlassSwitchMode;
  21. SerializedProperty GlassesErrorTipPrefab;
  22. SerializedProperty TrackingModeChangeTipPrefab;
  23. SerializedProperty ProjectConfig;
  24. private void OnEnable()
  25. {
  26. NRSessionConfig sessionConfig = (NRSessionConfig)target;
  27. sessionConfig.SetProjectConfig(NRProjectConfigHelper.GetProjectConfig());
  28. // Setup the SerializedProperties
  29. PlaneFindingMode = serializedObject.FindProperty("PlaneFindingMode");
  30. ImageTrackingMode = serializedObject.FindProperty("ImageTrackingMode");
  31. TrackingImageDatabase = serializedObject.FindProperty("TrackingImageDatabase");
  32. EnableNotification = serializedObject.FindProperty("EnableNotification");
  33. ForceKillWhileGlassSwitchMode = serializedObject.FindProperty("ForceKillWhileGlassSwitchMode");
  34. GlassesErrorTipPrefab = serializedObject.FindProperty("GlassesErrorTipPrefab");
  35. TrackingModeChangeTipPrefab = serializedObject.FindProperty("TrackingModeChangeTipPrefab");
  36. ProjectConfig = serializedObject.FindProperty("ProjectConfig");
  37. }
  38. override public void OnInspectorGUI()
  39. {
  40. NRSessionConfig sessionConfig = (NRSessionConfig)target;
  41. serializedObject.Update();
  42. // EditorGUILayout.PropertyField(ProjectConfig);
  43. NRProjectConfig projectConfig = NRProjectConfigHelper.GetProjectConfig();
  44. //NRProjectConfigEditor.DrawUniqueProjectConfig(projectConfig);
  45. EditorGUILayout.Space();
  46. EditorGUILayout.PropertyField(PlaneFindingMode);
  47. EditorGUILayout.PropertyField(ImageTrackingMode);
  48. EditorGUILayout.PropertyField(TrackingImageDatabase);
  49. EditorGUILayout.PropertyField(EnableNotification);
  50. EditorGUILayout.PropertyField(ForceKillWhileGlassSwitchMode);
  51. EditorGUILayout.Space();
  52. EditorGUILayout.PropertyField(GlassesErrorTipPrefab);
  53. EditorGUILayout.PropertyField(TrackingModeChangeTipPrefab);
  54. // Apply values to the target
  55. serializedObject.ApplyModifiedProperties();
  56. //Provide link to the unique NRProjectConfig
  57. if (GUILayout.Button("Open NRProjectConfig"))
  58. {
  59. Selection.activeObject = sessionConfig.GlobalProjectConfig;
  60. }
  61. }
  62. }
  63. }