GitHub Enterprise
4 年前
当前提交
370af9f4
共有 23 个文件被更改,包括 2071 次插入 和 1 次删除
-
230Assets/Scenes/ARFoundationMenu/Menu.unity
-
5Assets/Scripts/UX/ARSceneSelectUI.cs
-
13Assets/Scripts/UX/CheckAvailableFeatures.cs
-
3ProjectSettings/EditorBuildSettings.asset
-
4README.md
-
8Assets/Scenes/ThermalState.meta
-
8Assets/Scenes/ThermalState/Prefabs.meta
-
98Assets/Scenes/ThermalState/Prefabs/SimpleMesh.prefab
-
7Assets/Scenes/ThermalState/Prefabs/SimpleMesh.prefab.meta
-
8Assets/Scenes/ThermalState/Scripts.meta
-
1001Assets/Scenes/ThermalState/ThermalState.unity
-
7Assets/Scenes/ThermalState/ThermalState.unity.meta
-
11Assets/Scenes/ThermalState/Scripts/FeaturesReporting.cs.meta
-
147Assets/Scenes/ThermalState/Scripts/ThermalStateForIOS.cs
-
11Assets/Scenes/ThermalState/Scripts/ThermalStateForIOS.cs.meta
-
47Assets/Scenes/ThermalState/Scripts/ThermalStateForIOSProvider.mm
-
37Assets/Scenes/ThermalState/Scripts/ThermalStateForIOSProvider.mm.meta
-
204Assets/Scenes/ThermalState/Scripts/ThermalStateHandling.cs
-
11Assets/Scenes/ThermalState/Scripts/ThermalStateHandling.cs.meta
-
212Assets/Scenes/ThermalState/Scripts/FeaturesReporting.cs
|
|||
fileFormatVersion: 2 |
|||
guid: 8326044ec302a44fc81b17b2b68576b8 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: a2bb3ad8a77cf4165a64050458de4c38 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &628810306991918854 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1334555916045423617} |
|||
- component: {fileID: 3164683533026836259} |
|||
- component: {fileID: 5509717854409629217} |
|||
- component: {fileID: 1592233981980384025} |
|||
m_Layer: 0 |
|||
m_Name: SimpleMesh |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &1334555916045423617 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 628810306991918854} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!33 &3164683533026836259 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 628810306991918854} |
|||
m_Mesh: {fileID: 0} |
|||
--- !u!23 &5509717854409629217 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 628810306991918854} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RayTraceProcedural: 0 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 2100000, guid: e01257fbb05e84833a5beb1792546158, type: 2} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
m_AdditionalVertexStreams: {fileID: 0} |
|||
--- !u!64 &1592233981980384025 |
|||
MeshCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 628810306991918854} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 4 |
|||
m_Convex: 0 |
|||
m_CookingOptions: 30 |
|||
m_Mesh: {fileID: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: 481ab5ad50c684d128841668c492e601 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: fccca18c31f2c4301b7868e8b79dae92 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Assets/Scenes/ThermalState/ThermalState.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: e5b0cb11dfe354e67a344c280bf8b611 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ae0dd90ee676041d5a821647cb367fc7 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Runtime.InteropServices; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
/// <summary>
|
|||
/// A component that provides functionality to query for thermal state on iOS devices and to subscribe to an event
|
|||
/// that fires when the thermal state changes.
|
|||
/// </summary>
|
|||
public class ThermalStateForIOS : MonoBehaviour |
|||
{ |
|||
#if UNITY_IOS && !UNITY_EDITOR
|
|||
/// <summary>
|
|||
/// The thermal state on the previous update, used for determining when to fire the state changed event.
|
|||
/// </summary>
|
|||
ThermalState? m_PreviousThermalState; |
|||
#endif // UNITY_IOS && !UNITY_EDITOR
|
|||
|
|||
/// <summary>
|
|||
/// Event that fires when the thermal state has changed.
|
|||
/// </summary>
|
|||
public Action<ThermalStateChange> stateChanged; |
|||
|
|||
/// <summary>
|
|||
/// iOS thermal states as documented by
|
|||
/// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/RespondToThermalStateChanges.html
|
|||
/// <summary>
|
|||
public enum ThermalState |
|||
{ |
|||
/// <summary>
|
|||
/// Thermal state is unknown.
|
|||
/// </summary>
|
|||
[Description("Unknown")] |
|||
Unknown = 0, |
|||
|
|||
/// <summary>
|
|||
/// The thermal state is at an acceptable level.
|
|||
/// </summary>
|
|||
[Description("Nominal")] |
|||
Nominal = 1, |
|||
|
|||
/// <summary>
|
|||
/// The thermal state is minimally elevated.
|
|||
/// </summary>
|
|||
[Description("Fair")] |
|||
Fair = 2, |
|||
|
|||
/// <summary>
|
|||
/// The thermal state is highly elevated.
|
|||
/// </summary>
|
|||
[Description("Serious")] |
|||
Serious = 3, |
|||
|
|||
/// <summary>
|
|||
/// The thermal state is significantly elevated.
|
|||
/// </summary>
|
|||
[Description("Critical")] |
|||
Critical = 4, |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Queries the current thermal state of the iOS device.
|
|||
/// </summary>
|
|||
public ThermalState currentThermalState => NativeApi.GetCurrentThermalState(); |
|||
|
|||
#if UNITY_IOS && !UNITY_EDITOR
|
|||
/// <summary>
|
|||
/// On enable, initialize the previous thermal state to null.
|
|||
/// </summary>
|
|||
void OnEnable() |
|||
{ |
|||
m_PreviousThermalState = null; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// On each update, query the current thermal state, and fire the state changed event if the thermal state has
|
|||
/// changed since the previous update.
|
|||
/// </summary>
|
|||
void Update() |
|||
{ |
|||
ThermalState thermalState = currentThermalState; |
|||
|
|||
if (m_PreviousThermalState.HasValue && (thermalState != m_PreviousThermalState.Value)) |
|||
{ |
|||
if (stateChanged != null) |
|||
{ |
|||
stateChanged(new ThermalStateChange(m_PreviousThermalState.Value, thermalState)); |
|||
} |
|||
} |
|||
|
|||
m_PreviousThermalState = thermalState; |
|||
} |
|||
#endif // UNITY_IOS && !UNITY_EDITOR
|
|||
|
|||
/// <summary>
|
|||
/// Struct containing both the previous and current thermal states when a state change occurs.
|
|||
/// </summary>
|
|||
public struct ThermalStateChange |
|||
{ |
|||
/// <summary>
|
|||
/// The previous thermal state for a state change event.
|
|||
/// </summary>
|
|||
ThermalState m_PreviousThermalState; |
|||
|
|||
/// <summary>
|
|||
/// The current thermal state for a state change event.
|
|||
/// </summary>
|
|||
ThermalState m_CurrentThermalState; |
|||
|
|||
/// <summary>
|
|||
/// The previous thermal state for a state change event.
|
|||
/// </summary>
|
|||
public ThermalState previousThermalState => m_PreviousThermalState; |
|||
|
|||
/// <summary>
|
|||
/// The current thermal state for a state change event.
|
|||
/// </summary>
|
|||
public ThermalState currentThermalState => m_CurrentThermalState; |
|||
|
|||
/// <summary>
|
|||
/// Constructs a thermal state change with the previous and current thermal states.
|
|||
/// </summary>
|
|||
/// <param name="previousThermalState">The previous thermal state for a state change event.</param>
|
|||
/// <param name="currentThermalState">The current thermal state for a state change event.</param>
|
|||
public ThermalStateChange (ThermalState previousThermalState, ThermalState currentThermalState) |
|||
{ |
|||
m_PreviousThermalState = previousThermalState; |
|||
m_CurrentThermalState = currentThermalState; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Native API for querying the thermal state on iOS. For other platforms, this API is stubbed out.
|
|||
/// /<summary>
|
|||
static class NativeApi |
|||
{ |
|||
#if UNITY_IOS && !UNITY_EDITOR
|
|||
[DllImport("__Internal", EntryPoint = "ARFoundationSamples_GetCurrentThermalState")] |
|||
public static extern ThermalState GetCurrentThermalState(); |
|||
#else // UNITY_IOS && !UNITY_EDITOR
|
|||
public static ThermalState GetCurrentThermalState() => ThermalState.Unknown; |
|||
#endif // UNITY_IOS && !UNITY_EDITOR
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6799e8e2720634b88b4605c0315c05b1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#import <Foundation/NSProcessInfo.h> |
|||
|
|||
#define EXPORT(_returnType_) extern "C" _returnType_ __attribute__ ((visibility ("default"))) |
|||
|
|||
namespace |
|||
{ |
|||
// Values must match UnityEngine.XR.ARFoundation.Samples.ThermalStateForIOS.ThermalState |
|||
enum ThermalState |
|||
{ |
|||
kThermalStateUnknown = 0, |
|||
kThermalStateNominal = 1, |
|||
kThermalStateFair = 2, |
|||
kThermalStateSerious = 3, |
|||
kThermalStateCritical = 4, |
|||
}; |
|||
|
|||
inline ThermalState ConvertThermalState(NSProcessInfoThermalState thermalState) |
|||
{ |
|||
ThermalState returnValue; |
|||
|
|||
switch (thermalState) |
|||
{ |
|||
case NSProcessInfoThermalStateNominal: |
|||
returnValue = kThermalStateNominal; |
|||
break; |
|||
case NSProcessInfoThermalStateFair: |
|||
returnValue = kThermalStateFair; |
|||
break; |
|||
case NSProcessInfoThermalStateSerious: |
|||
returnValue = kThermalStateSerious; |
|||
break; |
|||
case NSProcessInfoThermalStateCritical: |
|||
returnValue = kThermalStateCritical; |
|||
break; |
|||
default: |
|||
returnValue = kThermalStateUnknown; |
|||
break; |
|||
} |
|||
|
|||
return returnValue; |
|||
} |
|||
} |
|||
|
|||
EXPORT(ThermalState) ARFoundationSamples_GetCurrentThermalState() |
|||
{ |
|||
return ::ConvertThermalState([[NSProcessInfo processInfo] thermalState]); |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2fa0ad5f54cd343c781cbd116aaf8ef7 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
iPhone: iOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
tvOS: tvOS |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.XR.ARFoundation; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class ThermalStateHandling : MonoBehaviour |
|||
{ |
|||
/// <summary>
|
|||
/// The environment probe manager.
|
|||
/// </summary>
|
|||
AREnvironmentProbeManager m_EnvironmentProbeManager; |
|||
|
|||
/// <summary>
|
|||
/// The face manager.
|
|||
/// </summary>
|
|||
ARFaceManager m_FaceManager; |
|||
|
|||
/// <summary>
|
|||
/// The mesh manager.
|
|||
/// </summary>
|
|||
ARMeshManager m_MeshManager; |
|||
|
|||
/// <summary>
|
|||
/// The occlusion manager.
|
|||
/// </summary>
|
|||
AROcclusionManager m_OcclusionManager; |
|||
|
|||
/// <summary>
|
|||
/// The AR session.
|
|||
/// </summary>
|
|||
ARSession m_Session; |
|||
|
|||
/// <summary>
|
|||
/// The component from which to query the thermal state.
|
|||
/// </summary>
|
|||
public ThermalStateForIOS thermalStateForIOS |
|||
{ |
|||
get => m_ThermalStateForIOS; |
|||
set => m_ThermalStateForIOS = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
ThermalStateForIOS m_ThermalStateForIOS; |
|||
|
|||
/// <summary>
|
|||
/// The text UI to update with the current thermal state.
|
|||
/// </summary>
|
|||
public Text thermalStateText |
|||
{ |
|||
get => m_ThermalStateText; |
|||
set => m_ThermalStateText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
public Text m_ThermalStateText; |
|||
|
|||
/// <summary>
|
|||
/// On awake, find all of the AR components.
|
|||
/// </summary>
|
|||
void Awake() |
|||
{ |
|||
m_EnvironmentProbeManager = FindObjectOfType<AREnvironmentProbeManager>(); |
|||
m_FaceManager = FindObjectOfType<ARFaceManager>(); |
|||
m_MeshManager = FindObjectOfType<ARMeshManager>(); |
|||
m_OcclusionManager = FindObjectOfType<AROcclusionManager>(); |
|||
m_Session = FindObjectOfType<ARSession>(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// On enable, update the current thermal state text, set the AR features, and subscribe to the thermal state
|
|||
/// change event.
|
|||
/// </summary>
|
|||
void OnEnable() |
|||
{ |
|||
Debug.Assert(m_ThermalStateForIOS != null, "ThermalStateForIOS cannot be null"); |
|||
Debug.Assert(m_ThermalStateText != null, "ThermalStateText cannot be null"); |
|||
|
|||
ThermalStateForIOS.ThermalState thermalState = m_ThermalStateForIOS.currentThermalState; |
|||
m_ThermalStateText.text = $"Thermal State: {thermalState}"; |
|||
|
|||
SetARFeaturesBasedOnThermalState(thermalState); |
|||
|
|||
m_ThermalStateForIOS.stateChanged += OnThermalStateChanged; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// On disable, update the current thermal state text, and unsubscribe to the thermal state change event.
|
|||
/// </summary>
|
|||
void OnDisable() |
|||
{ |
|||
Debug.Assert(m_ThermalStateForIOS != null, "ThermalStateForIOS cannot be null"); |
|||
Debug.Assert(m_ThermalStateText != null, "ThermalStateText cannot be null"); |
|||
|
|||
m_ThermalStateText.text = $"Thermal State: {ThermalStateForIOS.ThermalState.Unknown}"; |
|||
|
|||
m_ThermalStateForIOS.stateChanged -= OnThermalStateChanged; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// When the thermal state changes, update the thermal state text UI, and set the AR features based on the
|
|||
/// current thermal state.
|
|||
/// </summary>
|
|||
void OnThermalStateChanged(ThermalStateForIOS.ThermalStateChange thermalStateChangeArgs) |
|||
{ |
|||
m_ThermalStateText.text = $"Thermal State: {thermalStateChangeArgs.currentThermalState}"; |
|||
SetARFeaturesBasedOnThermalState(thermalStateChangeArgs.currentThermalState); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Enable/disable AR features based on the thermal state in an effort to reduce power in elevated thermal
|
|||
/// states.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Note that these particular features for each thermal state are just for demo purposes only. Developers
|
|||
/// should decide which features are most critical for their own apps.
|
|||
/// </summary>
|
|||
void SetARFeaturesBasedOnThermalState(ThermalStateForIOS.ThermalState thermalState) |
|||
{ |
|||
switch (thermalState) |
|||
{ |
|||
case ThermalStateForIOS.ThermalState.Nominal: |
|||
ToggleEnvironmentProbeFeature(true); |
|||
ToggleFaceTrackingFeature(true); |
|||
ToggleMeshingFeature(true); |
|||
ToggleHumanSegmentationFeatures(true); |
|||
ToggleEnvironmentDepthFeature(true); |
|||
ToggleARSession(true); |
|||
break; |
|||
case ThermalStateForIOS.ThermalState.Fair: |
|||
ToggleEnvironmentProbeFeature(false); |
|||
ToggleFaceTrackingFeature(false); |
|||
ToggleMeshingFeature(false); |
|||
ToggleHumanSegmentationFeatures(false); |
|||
ToggleEnvironmentDepthFeature(true); |
|||
ToggleARSession(true); |
|||
break; |
|||
case ThermalStateForIOS.ThermalState.Serious: |
|||
ToggleEnvironmentProbeFeature(false); |
|||
ToggleFaceTrackingFeature(false); |
|||
ToggleMeshingFeature(false); |
|||
ToggleHumanSegmentationFeatures(false); |
|||
ToggleEnvironmentDepthFeature(false); |
|||
ToggleARSession(true); |
|||
break; |
|||
case ThermalStateForIOS.ThermalState.Critical: |
|||
ToggleEnvironmentProbeFeature(false); |
|||
ToggleFaceTrackingFeature(false); |
|||
ToggleMeshingFeature(false); |
|||
ToggleHumanSegmentationFeatures(false); |
|||
ToggleEnvironmentDepthFeature(false); |
|||
ToggleARSession(false); |
|||
break; |
|||
case ThermalStateForIOS.ThermalState.Unknown: |
|||
default: |
|||
ToggleEnvironmentProbeFeature(true); |
|||
ToggleFaceTrackingFeature(true); |
|||
ToggleMeshingFeature(true); |
|||
ToggleHumanSegmentationFeatures(true); |
|||
ToggleEnvironmentDepthFeature(true); |
|||
ToggleARSession(true); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void ToggleEnvironmentProbeFeature(bool active) |
|||
{ |
|||
Debug.Assert(m_EnvironmentProbeManager != null, "environment probe manager not found"); |
|||
m_EnvironmentProbeManager.enabled = active; |
|||
} |
|||
|
|||
void ToggleFaceTrackingFeature(bool active) |
|||
{ |
|||
Debug.Assert(m_FaceManager != null, "face manager not found"); |
|||
m_FaceManager.enabled = active; |
|||
} |
|||
|
|||
void ToggleMeshingFeature(bool active) |
|||
{ |
|||
Debug.Assert(m_MeshManager != null, "mesh manager not found"); |
|||
m_MeshManager.enabled = active; |
|||
} |
|||
|
|||
void ToggleHumanSegmentationFeatures(bool active) |
|||
{ |
|||
Debug.Assert(m_OcclusionManager != null, "occlusion manager not found"); |
|||
m_OcclusionManager.requestedHumanDepthMode = active ? HumanSegmentationDepthMode.Best : HumanSegmentationDepthMode.Disabled; |
|||
m_OcclusionManager.requestedHumanStencilMode = active ? HumanSegmentationStencilMode.Best : HumanSegmentationStencilMode.Disabled; |
|||
} |
|||
|
|||
void ToggleEnvironmentDepthFeature(bool active) |
|||
{ |
|||
Debug.Assert(m_OcclusionManager != null, "occlusion manager not found"); |
|||
m_OcclusionManager.requestedEnvironmentDepthMode = active ? EnvironmentDepthMode.Best : EnvironmentDepthMode.Disabled; |
|||
} |
|||
|
|||
void ToggleARSession(bool active) |
|||
{ |
|||
Debug.Assert(m_MeshManager != null, "AR session not found"); |
|||
m_Session.enabled = active; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b9a75ddfff96e4c9a945b81c1c78f9c9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.XR.ARFoundation; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
#if UNITY_IOS && !UNITY_EDITOR
|
|||
using UnityEngine.XR.ARKit; |
|||
#endif // UNITY_IOS && !UNITY_EDITOR
|
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class FeaturesReporting : MonoBehaviour |
|||
{ |
|||
public Text autoFocusText |
|||
{ |
|||
get => m_AutoFocusText; |
|||
set => m_AutoFocusText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_AutoFocusText; |
|||
|
|||
public Text environmentDepthText |
|||
{ |
|||
get => m_EnvironmentDepthText; |
|||
set => m_EnvironmentDepthText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_EnvironmentDepthText; |
|||
|
|||
public Text environmentProbesText |
|||
{ |
|||
get => m_EnvironmentProbesText; |
|||
set => m_EnvironmentProbesText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_EnvironmentProbesText; |
|||
|
|||
public Text faceTrackingText |
|||
{ |
|||
get => m_FaceTrackingText; |
|||
set => m_FaceTrackingText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_FaceTrackingText; |
|||
|
|||
public Text humanDepthText |
|||
{ |
|||
get => m_HumanDepthText; |
|||
set => m_HumanDepthText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_HumanDepthText; |
|||
|
|||
public Text humanStencilText |
|||
{ |
|||
get => m_HumanStencilText; |
|||
set => m_HumanStencilText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_HumanStencilText; |
|||
|
|||
public Text lightEstimationColorText |
|||
{ |
|||
get => m_LightEstimationColorText; |
|||
set => m_LightEstimationColorText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_LightEstimationColorText; |
|||
|
|||
public Text lightEstimationIntensityText |
|||
{ |
|||
get => m_LightEstimationIntensityText; |
|||
set => m_LightEstimationIntensityText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_LightEstimationIntensityText; |
|||
|
|||
public Text meshingText |
|||
{ |
|||
get => m_MeshingText; |
|||
set => m_MeshingText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_MeshingText; |
|||
|
|||
public Text meshingClassificationText |
|||
{ |
|||
get => m_MeshingClassificationText; |
|||
set => m_MeshingClassificationText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_MeshingClassificationText; |
|||
|
|||
public Text planeTrackingText |
|||
{ |
|||
get => m_PlaneTrackingText; |
|||
set => m_PlaneTrackingText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_PlaneTrackingText; |
|||
|
|||
public Text raycastingText |
|||
{ |
|||
get => m_RaycastingText; |
|||
set => m_RaycastingText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_RaycastingText; |
|||
|
|||
public Text rotationAndOrientationText |
|||
{ |
|||
get => m_RotationAndOrientationText; |
|||
set => m_RotationAndOrientationText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_RotationAndOrientationText; |
|||
|
|||
public Text worldFacingCameraText |
|||
{ |
|||
get => m_WorldFacingCameraText; |
|||
set => m_WorldFacingCameraText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_WorldFacingCameraText; |
|||
|
|||
public Text sessionFpsText |
|||
{ |
|||
get => m_SessionFpsText; |
|||
set => m_SessionFpsText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_SessionFpsText; |
|||
|
|||
ARCameraManager m_CameraManager; |
|||
AREnvironmentProbeManager m_EnvironmentProbeManager; |
|||
ARFaceManager m_FaceManager; |
|||
ARMeshManager m_MeshManager; |
|||
AROcclusionManager m_OcclusionManager; |
|||
ARPlaneManager m_PlaneManager; |
|||
ARRaycastManager m_RaycastManager; |
|||
ARSession m_Session; |
|||
|
|||
void Awake() |
|||
{ |
|||
m_CameraManager = FindObjectOfType<ARCameraManager>(); |
|||
m_EnvironmentProbeManager = FindObjectOfType<AREnvironmentProbeManager>(); |
|||
m_FaceManager = FindObjectOfType<ARFaceManager>(); |
|||
m_MeshManager = FindObjectOfType<ARMeshManager>(); |
|||
m_OcclusionManager = FindObjectOfType<AROcclusionManager>(); |
|||
m_PlaneManager = FindObjectOfType<ARPlaneManager>(); |
|||
m_RaycastManager = FindObjectOfType<ARRaycastManager>(); |
|||
m_Session = FindObjectOfType<ARSession>(); |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
bool isARSessionEnabled = m_Session && (m_Session.subsystem?.running ?? false); |
|||
bool isCameraManagerEnabled = isARSessionEnabled && m_CameraManager && (m_CameraManager.subsystem?.running ?? false); |
|||
bool isEnvironmentProbeManagerEnabled = isARSessionEnabled && m_EnvironmentProbeManager && (m_EnvironmentProbeManager.subsystem?.running ?? false); |
|||
bool isFaceManagerEnabled = isARSessionEnabled && m_FaceManager && (m_FaceManager.subsystem?.running ?? false); |
|||
bool isMeshManagerEnabled = isARSessionEnabled && m_MeshManager && (m_MeshManager.subsystem?.running ?? false); |
|||
bool isOcclusionManagerEnabled = isARSessionEnabled && m_OcclusionManager && (m_OcclusionManager.subsystem?.running ?? false); |
|||
bool isPlaneManagerEnabled = isARSessionEnabled && m_PlaneManager && (m_PlaneManager.subsystem?.running ?? false); |
|||
bool isRaycastManagerEnabled = isARSessionEnabled && m_RaycastManager && (m_RaycastManager.subsystem?.running ?? false); |
|||
|
|||
SetFeatureDisplayState(m_AutoFocusText, isCameraManagerEnabled && m_CameraManager.autoFocusEnabled); |
|||
SetFeatureDisplayState(m_EnvironmentDepthText, isOcclusionManagerEnabled && m_OcclusionManager.currentEnvironmentDepthMode.Enabled()); |
|||
SetFeatureDisplayState(m_EnvironmentProbesText, isEnvironmentProbeManagerEnabled); |
|||
SetFeatureDisplayState(m_FaceTrackingText, isFaceManagerEnabled && (m_FaceManager.supportedFaceCount > 0)); |
|||
SetFeatureDisplayState(m_HumanDepthText, isOcclusionManagerEnabled && m_OcclusionManager.currentHumanDepthMode.Enabled()); |
|||
SetFeatureDisplayState(m_HumanStencilText, isOcclusionManagerEnabled && m_OcclusionManager.currentHumanStencilMode.Enabled()); |
|||
SetFeatureDisplayState(m_LightEstimationColorText, isCameraManagerEnabled && ((m_CameraManager.currentLightEstimation & LightEstimation.AmbientColor) == LightEstimation.AmbientColor)); |
|||
SetFeatureDisplayState(m_LightEstimationIntensityText, isCameraManagerEnabled && ((m_CameraManager.currentLightEstimation & LightEstimation.AmbientIntensity) == LightEstimation.AmbientIntensity)); |
|||
SetFeatureDisplayState(m_MeshingText, isMeshManagerEnabled); |
|||
#if UNITY_IOS && !UNITY_EDITOR
|
|||
{ |
|||
XRMeshSubsystem meshSubsystem = m_MeshManager?.subsystem as XRMeshSubsystem; |
|||
SetFeatureDisplayState(m_MeshingClassificationText, isMeshManagerEnabled && meshSubsystem.GetClassificationEnabled()); |
|||
} |
|||
#else // UNITY_IOS && !UNITY_EDITOR
|
|||
SetFeatureDisplayState(m_MeshingClassificationText, false); |
|||
#endif // UNITY_IOS && !UNITY_EDITOR
|
|||
SetFeatureDisplayState(m_PlaneTrackingText, isPlaneManagerEnabled && (m_PlaneManager.currentDetectionMode != PlaneDetectionMode.None)); |
|||
SetFeatureDisplayState(m_RaycastingText, isRaycastManagerEnabled); |
|||
SetFeatureDisplayState(m_RotationAndOrientationText, isARSessionEnabled && (m_Session.currentTrackingMode == TrackingMode.PositionAndRotation)); |
|||
SetFeatureDisplayState(m_WorldFacingCameraText, isCameraManagerEnabled && (m_CameraManager.currentFacingDirection == CameraFacingDirection.World)); |
|||
SetFeatureDisplayState(m_SessionFpsText, isARSessionEnabled); |
|||
|
|||
int arFrameRate = isARSessionEnabled ? (m_Session.frameRate ?? 0) : 0; |
|||
m_SessionFpsText.text = $"AR Session FPS: {arFrameRate}"; |
|||
} |
|||
|
|||
void SetFeatureDisplayState(Text textUI, bool isActive) |
|||
{ |
|||
textUI.color = isActive ? Color.green : Color.red; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue