Initialer Upload neues Unity-Projekt

This commit is contained in:
Daniel Ocks
2025-07-21 09:11:14 +02:00
commit eeca72985b
14558 changed files with 1508140 additions and 0 deletions

View File

@ -0,0 +1,249 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if USING_XR_SDK_OPENXR
using System;
using System.Runtime.InteropServices;
using AOT;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using UnityEngine.XR.OpenXR.Features;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.XR.OpenXR;
using UnityEditor.XR.OpenXR.Features;
using UnityEditor.Build.Reporting;
#endif
namespace Meta.XR
{
#if UNITY_EDITOR
public class MetaXRFeatureEditorConfig
{
public const string OpenXrExtensionList =
"XR_KHR_vulkan_enable " +
"XR_KHR_D3D11_enable " +
"XR_OCULUS_common_reference_spaces " +
"XR_FB_display_refresh_rate " +
"XR_EXT_performance_settings " +
"XR_FB_composition_layer_image_layout " +
"XR_KHR_android_surface_swapchain " +
"XR_FB_android_surface_swapchain_create " +
"XR_KHR_composition_layer_color_scale_bias " +
"XR_FB_color_space " +
"XR_EXT_hand_tracking " +
"XR_FB_swapchain_update_state " +
"XR_FB_swapchain_update_state_opengl_es " +
"XR_FB_swapchain_update_state_vulkan " +
"XR_FB_composition_layer_alpha_blend " +
"XR_KHR_composition_layer_depth " +
"XR_KHR_composition_layer_cylinder " +
"XR_KHR_composition_layer_cube " +
"XR_KHR_composition_layer_equirect2 " +
"XR_KHR_convert_timespec_time " +
"XR_KHR_visibility_mask " +
"XR_FB_render_model " +
"XR_FB_spatial_entity " +
"XR_FB_spatial_entity_query " +
"XR_FB_spatial_entity_storage " +
"XR_META_performance_metrics " +
"XR_FB_scene " +
"XR_FB_spatial_entity_container " +
"XR_FB_scene_capture " +
"XR_FB_face_tracking " +
"XR_FB_eye_tracking " +
"XR_FB_keyboard_tracking " +
"XR_FB_passthrough " +
"XR_FB_triangle_mesh " +
"XR_FB_passthrough_keyboard_hands " +
"XR_OCULUS_audio_device_guid " +
"XR_FB_common_events " +
"XR_FB_space_warp " +
"XR_FB_hand_tracking_capsules " +
"XR_FB_hand_tracking_mesh " +
"XR_FB_hand_tracking_aim " +
"XR_FB_touch_controller_pro " +
"XR_FB_touch_controller_proximity " +
""
;
}
#endif
/// <summary>
/// MetaXR Feature for OpenXR
/// </summary>
#if UNITY_EDITOR
[OpenXRFeature(UiName = "Meta XR Feature",
BuildTargetGroups = new[] { BuildTargetGroup.Standalone, BuildTargetGroup.Android },
Company = "Meta",
Desc = "Meta XR Feature for OpenXR.",
DocumentationLink = "https://developer.oculus.com/",
OpenxrExtensionStrings = MetaXRFeatureEditorConfig.OpenXrExtensionList,
Version = "0.0.1",
FeatureId = featureId)]
#endif
public class MetaXRFeature : OpenXRFeature
{
/// <summary>
/// The feature id string. This is used to give the feature a well known id for reference.
/// </summary>
public const string featureId = "com.meta.openxr.feature.metaxr";
/// <inheritdoc />
protected override IntPtr HookGetInstanceProcAddr(IntPtr func)
{
OVRPlugin.UnityOpenXR.Enabled = true;
Debug.Log($"[MetaXRFeature] HookGetInstanceProcAddr: {func}");
Debug.Log($"[MetaXRFeature] SetClientVersion");
OVRPlugin.UnityOpenXR.SetClientVersion();
return OVRPlugin.UnityOpenXR.HookGetInstanceProcAddr(func);
}
/// <inheritdoc />
protected override bool OnInstanceCreate(ulong xrInstance)
{
bool isMetaHeadsetIdSupported = false;
string[] extensions = OpenXRRuntime.GetAvailableExtensions();
foreach (string extension in extensions)
{
if (extension == "XR_META_headset_id")
{
isMetaHeadsetIdSupported = true;
break;
}
}
if (isMetaHeadsetIdSupported)
{
Debug.Log("[MetaXRFeature] OpenXR runtime supports XR_META_headset_id extension. MetaXRFeature is enabled.");
}
else
{
// The runtime name string will be used to support old runtime versions which misses XR_META_headset_id extension.
// This path should be removed in the future.
string runtimeNameLowercase = OpenXRRuntime.name.ToLower();
if (!runtimeNameLowercase.Contains("meta") && !runtimeNameLowercase.Contains("oculus"))
{
// disable MetaXRFeature from non-Oculus/Meta OpenXR runtimes
Debug.LogWarningFormat("[MetaXRFeature] MetaXRFeature is disabled on non-Oculus/Meta OpenXR Runtime. Runtime name: {0}", OpenXRRuntime.name);
return false;
}
}
// here's one way you can grab the instance
Debug.Log($"[MetaXRFeature] OnInstanceCreate: {xrInstance}");
bool result = OVRPlugin.UnityOpenXR.OnInstanceCreate(xrInstance);
if (!result)
{
Debug.LogWarning("[MetaXRFeature] OnInstanceCreate returned an error. If you are using Quest Link, please verify if it's started.");
}
return result;
}
/// <inheritdoc />
protected override void OnInstanceDestroy(ulong xrInstance)
{
// here's one way you can grab the instance
Debug.Log($"[MetaXRFeature] OnInstanceDestroy: {xrInstance}");
OVRPlugin.UnityOpenXR.OnInstanceDestroy(xrInstance);
}
/// <inheritdoc />
protected override void OnSessionCreate(ulong xrSession)
{
// here's one way you can grab the session
Debug.Log($"[MetaXRFeature] OnSessionCreate: {xrSession}");
OVRPlugin.UnityOpenXR.OnSessionCreate(xrSession);
}
/// <inheritdoc />
protected override void OnAppSpaceChange(ulong xrSpace)
{
Debug.Log($"[MetaXRFeature] OnAppSpaceChange: {xrSpace}");
OVRPlugin.UnityOpenXR.OnAppSpaceChange(xrSpace);
}
/// <inheritdoc />
protected override void OnSessionStateChange(int oldState, int newState)
{
Debug.Log($"[MetaXRFeature] OnSessionStateChange: {oldState} -> {newState}");
OVRPlugin.UnityOpenXR.OnSessionStateChange(oldState, newState);
}
/// <inheritdoc />
protected override void OnSessionBegin(ulong xrSession)
{
Debug.Log($"[MetaXRFeature] OnSessionBegin: {xrSession}");
OVRPlugin.UnityOpenXR.OnSessionBegin(xrSession);
}
/// <inheritdoc />
protected override void OnSessionEnd(ulong xrSession)
{
Debug.Log($"[MetaXRFeature] OnSessionEnd: {xrSession}");
OVRPlugin.UnityOpenXR.OnSessionEnd(xrSession);
}
/// <inheritdoc />
protected override void OnSessionExiting(ulong xrSession)
{
Debug.Log($"[MetaXRFeature] OnSessionExiting: {xrSession}");
OVRPlugin.UnityOpenXR.OnSessionExiting(xrSession);
}
/// <inheritdoc />
protected override void OnSessionDestroy(ulong xrSession)
{
Debug.Log($"[MetaXRFeature] OnSessionDestroy: {xrSession}");
OVRPlugin.UnityOpenXR.OnSessionDestroy(xrSession);
}
// protected override void OnSessionLossPending(ulong xrSession) {}
// protected override void OnInstanceLossPending (ulong xrInstance) {}
// protected override void OnSystemChange(ulong xrSystem) {}
// protected override void OnFormFactorChange (int xrFormFactor) {}
// protected override void OnViewConfigurationTypeChange (int xrViewConfigurationType) {}
// protected override void OnEnvironmentBlendModeChange (int xrEnvironmentBlendMode) {}
// protected override void OnEnabledChange() {}
}
#if UNITY_EDITOR && UNITY_OPENXR_BOOT_CONFIG
internal class MetaXRBootConfig : OpenXRFeatureBuildHooks
{
public override int callbackOrder => 1;
public override Type featureType => typeof(MetaXRFeature);
protected override void OnPostGenerateGradleAndroidProjectExt(string path) {}
protected override void OnPostprocessBuildExt(BuildReport report) {}
protected override void OnPreprocessBuildExt(BuildReport report) {}
protected override void OnProcessBootConfigExt(BuildReport report, BootConfigBuilder builder)
{
builder.SetBootConfigValue("xr-meta-enabled", "1");
}
}
#endif
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1927c045052a06d49a9b21fdcaa26db6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,137 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if USING_XR_SDK_OPENXR
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using UnityEngine.XR.OpenXR.Features;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.XR.OpenXR;
using UnityEditor.XR.OpenXR.Features;
#endif
namespace Meta.XR
{
public enum FoveationMethod
{
FFR = 0,
}
#if UNITY_EDITOR
[OpenXRFeature(UiName = "Meta XR Foveation",
BuildTargetGroups = new[] { BuildTargetGroup.Standalone, BuildTargetGroup.Android },
Company = "Meta",
Desc = "MetaXR Foveation Feature that includes FFR",
DocumentationLink = "https://developer.oculus.com/",
OpenxrExtensionStrings = extensionList,
Version = "1.0.0",
FeatureId = featureId)]
#endif
public class MetaXRFoveationFeature : OpenXRFeature
{
public const string extensionList = "XR_FB_foveation " +
"XR_FB_foveation_configuration " +
"XR_FB_foveation_vulkan ";
public const string featureId = "com.meta.openxr.feature.foveation";
private static ulong _xrSession;
#if UNITY_OPENXR_1_5_3
private static UInt32 _foveatedRenderingLevel = 0;
private static UInt32 _useDynamicFoveation = 0;
#endif
protected override void OnSessionCreate(ulong xrSession)
{
_xrSession = xrSession;
}
public static OVRManager.FoveatedRenderingLevel foveatedRenderingLevel
{
get
{
#if UNITY_OPENXR_1_5_3
UInt32 level;
FBGetFoveationLevel(out level);
return (OVRManager.FoveatedRenderingLevel)level;
#else
Debug.LogWarning("Unable to set foveation level. Meta XR Foveation is not supported on this version of the OpenXR Provider. Please use 1.5.3 and above");
return OVRManager.FoveatedRenderingLevel.Off;
#endif
}
set
{
#if UNITY_OPENXR_1_5_3
if (value == OVRManager.FoveatedRenderingLevel.HighTop)
_foveatedRenderingLevel = (UInt32)OVRManager.FoveatedRenderingLevel.High;
else
_foveatedRenderingLevel = (UInt32)value;
FBSetFoveationLevel(_xrSession, _foveatedRenderingLevel, 0.0f, _useDynamicFoveation);
#else
Debug.LogWarning("Unable to get foveation level. Meta XR Foveation is not supported on this version of the OpenXR Provider. Please use 1.5.3 and above");
return;
#endif
}
}
public static bool useDynamicFoveatedRendering
{
get
{
#if UNITY_OPENXR_1_5_3
UInt32 dynamic;
FBGetFoveationLevel(out dynamic);
return dynamic != 0;
#else
Debug.LogWarning("Unable to set dynamic foveation. Meta XR Foveation is not supported on this version of the OpenXR Provider. Please use 1.5.3 and above");
return false;
#endif
}
set
{
#if UNITY_OPENXR_1_5_3
if (value)
_useDynamicFoveation = 1;
else
_useDynamicFoveation = 0;
FBSetFoveationLevel(_xrSession, _foveatedRenderingLevel, 0.0f, _useDynamicFoveation);
#else
Debug.LogWarning("Unable to get dynamic foveation. Meta XR Foveation is not supported on this version of the OpenXR Provider. Please use 1.5.3 and above");
return;
#endif
}
}
#region OpenXR Plugin DLL Imports
[DllImport("UnityOpenXR", EntryPoint = "FBSetFoveationLevel")]
private static extern void FBSetFoveationLevel(UInt64 session, UInt32 level, float verticalOffset, UInt32 dynamic);
[DllImport("UnityOpenXR", EntryPoint = "FBGetFoveationLevel")]
private static extern void FBGetFoveationLevel(out UInt32 level);
[DllImport("UnityOpenXR", EntryPoint = "FBGetFoveationDynamic")]
private static extern void FBGetFoveationDynamic(out UInt32 dynamic);
#endregion
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d28f705476c80d47acb3dfade3d3142
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: