Files
VR-WuKong/Packages/PICO Unity Integration SDK-3.3.2-20251111/Editor/PXR_XRLoaderUI.cs

64 lines
1.9 KiB
C#
Raw Normal View History

2025-11-13 17:40:28 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.XR.PXR;
using UnityEditor;
using UnityEditor.XR.Management;
using UnityEngine;
using UnityEngine.XR.Management;
#if UNITY_OPENXR
using UnityEngine.XR.OpenXR;
#endif
[XRCustomLoaderUI("Unity.XR.PXR.PXR_Loader", BuildTargetGroup.Standalone)]
[XRCustomLoaderUI("Unity.XR.PXR.PXR_Loader", BuildTargetGroup.Android)]
internal class PXR_XRLoaderUI : IXRCustomLoaderUI
{
public static readonly GUIContent k_LoaderName = new GUIContent("PICO");
protected float renderLineHeight = 0;
/// <inheritdoc/>
public float RequiredRenderHeight { get; protected set; }
public virtual void SetRenderedLineHeight(float height)
{
renderLineHeight = height;
RequiredRenderHeight = height;
}
protected Rect CalculateRectForContent(float xMin, float yMin, GUIStyle style, GUIContent content)
{
var size = style.CalcSize(content);
var rect = new Rect();
rect.xMin = xMin;
rect.yMin = yMin;
rect.width = size.x;
rect.height = renderLineHeight;
return rect;
}
public void OnGUI(Rect rect)
{
float xMin = rect.xMin;
float yMin = rect.yMin;
var labelRect = CalculateRectForContent(xMin, yMin, EditorStyles.toggle, k_LoaderName);
var newToggled = EditorGUI.ToggleLeft(labelRect, k_LoaderName, IsLoaderEnabled);
if (newToggled != IsLoaderEnabled)
{
IsLoaderEnabled = newToggled;
}
PXR_Utils.UpdateSDKSymbols();
}
public bool IsLoaderEnabled { get; set; }
public string[] IncompatibleLoaders => new string[]
{
"UnityEngine.XR.OpenXR.OpenXRLoader",
"UnityEngine.XR.WindowsMR.WindowsMRLoader",
"Unity.XR.Oculus.OculusLoader",
};
public BuildTargetGroup ActiveBuildTargetGroup { get; set; }
}