// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using UltimateXR.Devices; using UltimateXR.Editor.Core; using UltimateXR.Editor.Sdks; using UnityEditor; using UnityEngine; namespace UltimateXR.Editor.Devices { /// /// Custom Unity editor for components. Checks for SDK availability. /// [CustomEditor(typeof(UxrTrackingDevice), true)] public class UxrTrackingEditor : UnityEditor.Editor { #region Public Types & Data public const string PropertyHideAvatarInPassthrough = "_hideAvatarInPassthrough"; #endregion #region Unity /// /// Checks if the given tracking component needs an SDK installed and available. Then draws the component itself. /// public override void OnInspectorGUI() { serializedObject.Update(); UxrTrackingDevice tracking = serializedObject.targetObject as UxrTrackingDevice; if (string.IsNullOrEmpty(tracking.SDKDependency) == false) { if (UxrSdkManager.IsAvailable(tracking.SDKDependency) == false) { EditorGUILayout.Space(); EditorGUILayout.HelpBox($"In order to work properly this component needs the following SDK installed and active: {tracking.SDKDependency}", MessageType.Warning); if (UxrEditorUtils.CenteredButton(new GUIContent("Check", "Go to the SDK Manager to check the SDK"))) { UxrSdkManagerWindow.ShowWindow(); } EditorGUILayout.Space(); } } if (tracking.IsMixedRealityDevice) { DrawPropertiesExcluding(serializedObject, "m_Script"); } else { DrawPropertiesExcluding(serializedObject, "m_Script", PropertyHideAvatarInPassthrough); } serializedObject.ApplyModifiedProperties(); } #endregion } }