Files
plugin-library/Assets/99.imdk_unity/Editor/DeviceLocalizationEditor.cs
2025-06-19 10:56:43 +08:00

70 lines
2.9 KiB
C#

/*===============================================================================
Copyright (C) 2024 Immersal - Part of Hexagon. All Rights Reserved.
This file is part of the Immersal SDK.
The Immersal SDK cannot be copied, distributed, or made available to
third-parties for commercial purposes without written permission of Immersal Ltd.
Contact sales@immersal.com for licensing requests.
===============================================================================*/
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace Immersal.XR
{
[CustomEditor(typeof(DeviceLocalization))]
public class DeviceLocalizationEditor : Editor
{
private SerializedProperty configurationMode;
private SerializedProperty solverTypeProperty;
private SerializedProperty priorNNCountProperty;
private SerializedProperty priorScaleProperty;
private SerializedProperty priorRadiusProperty;
private SerializedProperty onProgressEventProperty;
private void OnEnable()
{
configurationMode = serializedObject.FindProperty("m_ConfigurationMode");
solverTypeProperty = serializedObject.FindProperty("m_SolverType");
priorNNCountProperty = serializedObject.FindProperty("m_PriorNNCount");
priorRadiusProperty = serializedObject.FindProperty("m_PriorRadius");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
// Configuration mode
EditorGUILayout.HelpBox(configurationMode.enumValueIndex == (int)ConfigurationMode.Always ? "This localization method will be active even if there are no maps configured to use it." : "This localization method will only be active if there are maps configured to use it.", MessageType.Info);
configurationMode.enumValueIndex = EditorGUILayout.Popup("Configuration mode", configurationMode.enumValueIndex, configurationMode.enumNames);
EditorGUILayout.Separator();
if (solverTypeProperty.enumValueIndex is (int)SolverType.Prior or (int)SolverType.Lean)
{
EditorGUILayout.HelpBox("This Solver type is experimental. Extensive testing is advised.", MessageType.Warning);
}
// SolverType
solverTypeProperty.enumValueIndex = EditorGUILayout.Popup("Solver type", solverTypeProperty.enumValueIndex, solverTypeProperty.enumNames);
if (solverTypeProperty.enumValueIndex == (int)SolverType.Prior)
{
EditorGUILayout.PropertyField(priorNNCountProperty, new GUIContent("Nearest neighbour min"));
EditorGUILayout.PropertyField(priorRadiusProperty, new GUIContent("Radius"));
}
// Apply
serializedObject.ApplyModifiedProperties();
}
}
}
#endif