Shan Jiang
4 年前
当前提交
b52a295b
共有 16 个文件被更改,包括 1521 次插入 和 483 次删除
-
519Assets/Scenes/ARFoundationMenu/Menu.unity
-
5Assets/Scripts/UX/ARSceneSelectUI.cs
-
9Assets/Scripts/UX/CheckAvailableFeatures.cs
-
3ProjectSettings/EditorBuildSettings.asset
-
8Assets/Scenes/Configurations.meta
-
41Assets/Scripts/CameraSwapper.cs
-
11Assets/Scripts/CameraSwapper.cs.meta
-
141Assets/Scripts/CustomConfigurationChooser.cs
-
11Assets/Scripts/CustomConfigurationChooser.cs.meta
-
166Assets/Scripts/DisplayARSessionInformation.cs
-
11Assets/Scripts/DisplayARSessionInformation.cs.meta
-
7Assets/Scenes/Configurations/ConfigurationChooser.unity.meta
-
63Assets/Scenes/Configurations/ConfigurationChooserSettings.lighting
-
8Assets/Scenes/Configurations/ConfigurationChooserSettings.lighting.meta
-
1001Assets/Scenes/Configurations/ConfigurationChooser.unity
|
|||
fileFormatVersion: 2 |
|||
guid: c8b7d187eded9494aacba3b5d7216b2a |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class CameraSwapper : MonoBehaviour |
|||
{ |
|||
/// <summary>
|
|||
/// The camera manager for switching the camera direction.
|
|||
/// </summary>
|
|||
public ARCameraManager cameraManager |
|||
{ |
|||
get => m_CameraManager; |
|||
set => m_CameraManager = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
ARCameraManager m_CameraManager; |
|||
|
|||
/// <summary>
|
|||
/// On button press callback to toggle the requested camera facing direction.
|
|||
/// </summary>
|
|||
public void OnSwapCameraButtonPress() |
|||
{ |
|||
Debug.Assert(m_CameraManager != null, "camera manager cannot be null"); |
|||
CameraFacingDirection newFacingDirection; |
|||
switch (m_CameraManager.requestedFacingDirection) |
|||
{ |
|||
case CameraFacingDirection.World: |
|||
newFacingDirection = CameraFacingDirection.User; |
|||
break; |
|||
case CameraFacingDirection.User: |
|||
default: |
|||
newFacingDirection = CameraFacingDirection.World; |
|||
break; |
|||
} |
|||
|
|||
Debug.Log($"Switching ARCameraManager.requestedFacingDirection from {m_CameraManager.requestedFacingDirection} to {newFacingDirection}"); |
|||
m_CameraManager.requestedFacingDirection = newFacingDirection; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 29bd2bf6583a54738a6b2063140ee4ab |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.Collections; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class CustomConfigurationChooser : MonoBehaviour |
|||
{ |
|||
/// <summary>
|
|||
/// The configuration chooser mode. Values must match the UI dropdown.
|
|||
/// </summary>
|
|||
enum ConfigurationChooserMode |
|||
{ |
|||
Default = 0, |
|||
PreferCamera = 1, |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The AR session on which to set the configuration chooser.
|
|||
/// </summary>
|
|||
public ARSession session |
|||
{ |
|||
get => m_Session; |
|||
set => m_Session = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
ARSession m_Session; |
|||
|
|||
/// <summary>
|
|||
/// The instantiated instance of the default configuration chooser.
|
|||
/// </summary>
|
|||
static readonly ConfigurationChooser m_DefaultConfigurationChooser = new DefaultConfigurationChooser(); |
|||
|
|||
/// <summary>
|
|||
/// The instantiated instance of the prefer camera configuration chooser.
|
|||
/// </summary>
|
|||
static readonly ConfigurationChooser m_PreferCameraConfigurationChooser = new PreferCameraConfigurationChooser(); |
|||
|
|||
/// <summary>
|
|||
/// The current configuration chooser mode.
|
|||
/// </summary>
|
|||
ConfigurationChooserMode m_ConfigurationChooserMode = ConfigurationChooserMode.Default; |
|||
|
|||
void Start() |
|||
{ |
|||
UpdateConfigurationChooser(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Callback when the depth mode dropdown UI has a value change.
|
|||
/// </summary>
|
|||
/// <param name="dropdown">The dropdown UI that changed.</param>
|
|||
public void OnDepthModeDropdownValueChanged(Dropdown dropdown) |
|||
{ |
|||
// Update the display mode from the dropdown value.
|
|||
m_ConfigurationChooserMode = (ConfigurationChooserMode)dropdown.value; |
|||
|
|||
// Update the configuration chooser.
|
|||
UpdateConfigurationChooser(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Update the configuration chooser based on the current mode.
|
|||
/// </summary>
|
|||
void UpdateConfigurationChooser() |
|||
{ |
|||
Debug.Assert(m_Session != null, "ARSession must be nonnull"); |
|||
Debug.Assert(m_Session.subsystem != null, "ARSession must have a subsystem"); |
|||
switch (m_ConfigurationChooserMode) |
|||
{ |
|||
case ConfigurationChooserMode.PreferCamera: |
|||
m_Session.subsystem.configurationChooser = m_PreferCameraConfigurationChooser; |
|||
break; |
|||
case ConfigurationChooserMode.Default: |
|||
default: |
|||
m_Session.subsystem.configurationChooser = m_DefaultConfigurationChooser; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// A custom implementation of a <see cref="ConfigurationChooser"/>.
|
|||
/// </summary>
|
|||
class PreferCameraConfigurationChooser : ConfigurationChooser |
|||
{ |
|||
/// <summary>
|
|||
/// Selects a configuration from the given <paramref name="descriptors"/> and <paramref name="requestedFeatures"/>.
|
|||
/// </summary>
|
|||
public override Configuration ChooseConfiguration(NativeSlice<ConfigurationDescriptor> descriptors, Feature requestedFeatures) |
|||
{ |
|||
if (descriptors.Length == 0) |
|||
{ |
|||
throw new ArgumentException("No configuration descriptors to choose from.", nameof(descriptors)); |
|||
} |
|||
|
|||
if (requestedFeatures.Intersection(Feature.AnyTrackingMode).Count() > 1) |
|||
{ |
|||
throw new ArgumentException($"Zero or one tracking mode must be requested. Requested tracking modes => {requestedFeatures.Intersection(Feature.AnyTrackingMode).ToStringList()}", nameof(requestedFeatures)); |
|||
} |
|||
|
|||
if (requestedFeatures.Intersection(Feature.AnyCamera).Count() > 1) |
|||
{ |
|||
throw new ArgumentException($"Zero or one camera mode must be requested. Requested camera modes => {requestedFeatures.Intersection(Feature.AnyCamera).ToStringList()}", nameof(requestedFeatures)); |
|||
} |
|||
|
|||
// Get the requested camera features out of the set of requested features.
|
|||
Feature requestedCameraFeatures = requestedFeatures.Intersection(Feature.AnyCamera); |
|||
|
|||
int highestFeatureWeight = -1; |
|||
int highestRank = int.MinValue; |
|||
ConfigurationDescriptor bestDescriptor = default; |
|||
foreach (var descriptor in descriptors) |
|||
{ |
|||
// Initialize the feature weight with each feature being an equal weight.
|
|||
int featureWeight = requestedFeatures.Intersection(descriptor.capabilities).Count(); |
|||
|
|||
// Increase the weight if there are matching camera features.
|
|||
if (requestedCameraFeatures.Any(descriptor.capabilities)) |
|||
{ |
|||
featureWeight += 100; |
|||
} |
|||
|
|||
// Store the descriptor with the highest feature weight.
|
|||
if ((featureWeight > highestFeatureWeight) || |
|||
(featureWeight == highestFeatureWeight && descriptor.rank > highestRank)) |
|||
{ |
|||
highestFeatureWeight = featureWeight; |
|||
highestRank = descriptor.rank; |
|||
bestDescriptor = descriptor; |
|||
} |
|||
} |
|||
|
|||
// Return the configuration with the best matching descriptor.
|
|||
return new Configuration(bestDescriptor, requestedFeatures.Intersection(bestDescriptor.capabilities)); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f1cdc0d7a6c9d42ed9fe5aff9dbe95c3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Text; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class DisplayARSessionInformation : MonoBehaviour |
|||
{ |
|||
/// <summary>
|
|||
/// A string builder used for logging.
|
|||
/// </summary>
|
|||
readonly StringBuilder m_StringBuilder = new StringBuilder(); |
|||
|
|||
/// <summary>
|
|||
/// The text UI to display the logging information.
|
|||
/// </summary>
|
|||
public Text infoText |
|||
{ |
|||
get => m_InfoText; |
|||
set => m_InfoText = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
Text m_InfoText; |
|||
|
|||
/// <summary>
|
|||
/// The camera manager for logging.
|
|||
/// </summary>
|
|||
public ARCameraManager cameraManager |
|||
{ |
|||
get => m_CameraManager; |
|||
set => m_CameraManager = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
ARCameraManager m_CameraManager; |
|||
|
|||
/// <summary>
|
|||
/// The plane manager for logging.
|
|||
/// </summary>
|
|||
public ARPlaneManager planeManager |
|||
{ |
|||
get => m_PlaneManager; |
|||
set => m_PlaneManager = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
ARPlaneManager m_PlaneManager; |
|||
|
|||
/// <summary>
|
|||
/// The occlusion manager for logging.
|
|||
/// </summary>
|
|||
public AROcclusionManager occlusionManager |
|||
{ |
|||
get => m_OcclusionManager; |
|||
set => m_OcclusionManager = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
AROcclusionManager m_OcclusionManager; |
|||
|
|||
void Update() |
|||
{ |
|||
// Clear the string builder for a new log information.
|
|||
m_StringBuilder.Clear(); |
|||
|
|||
// Log the various manager states.
|
|||
BuildCameraMangerInfo(m_StringBuilder); |
|||
BuildPlaneMangerInfo(m_StringBuilder); |
|||
BuildOcclusionMangerInfo(m_StringBuilder); |
|||
|
|||
LogText(m_StringBuilder.ToString()); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Construct the camera manager information.
|
|||
/// </summary>
|
|||
void BuildCameraMangerInfo(StringBuilder stringBuilder) |
|||
{ |
|||
stringBuilder.AppendLine("ARCameraManager"); |
|||
if (m_CameraManager == null) |
|||
{ |
|||
stringBuilder.AppendLine(" <null>"); |
|||
} |
|||
else if (!m_CameraManager.enabled) |
|||
{ |
|||
stringBuilder.AppendLine(" <disabled>"); |
|||
} |
|||
else |
|||
{ |
|||
stringBuilder.AppendLine(" Facing direction:"); |
|||
stringBuilder.AppendLine($" Requested: {m_CameraManager.requestedFacingDirection}"); |
|||
stringBuilder.AppendLine($" Current: {m_CameraManager.currentFacingDirection}"); |
|||
stringBuilder.AppendLine(" Auto-focus:"); |
|||
stringBuilder.AppendLine($" Requested: {m_CameraManager.autoFocusRequested}"); |
|||
stringBuilder.AppendLine($" Current: {m_CameraManager.autoFocusEnabled}"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Construct the plane manager information.
|
|||
/// </summary>
|
|||
void BuildPlaneMangerInfo(StringBuilder stringBuilder) |
|||
{ |
|||
stringBuilder.AppendLine("ARPlaneManager"); |
|||
if (m_PlaneManager == null) |
|||
{ |
|||
stringBuilder.AppendLine(" <null>"); |
|||
} |
|||
else if (!m_PlaneManager.enabled) |
|||
{ |
|||
stringBuilder.AppendLine(" <disabled>"); |
|||
} |
|||
else |
|||
{ |
|||
stringBuilder.AppendLine(" Detection mode:"); |
|||
stringBuilder.AppendLine($" Requested: {m_PlaneManager.requestedDetectionMode}"); |
|||
stringBuilder.AppendLine($" Current: {m_PlaneManager.currentDetectionMode}"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Construct the occlusion manager information.
|
|||
/// </summary>
|
|||
void BuildOcclusionMangerInfo(StringBuilder stringBuilder) |
|||
{ |
|||
stringBuilder.AppendLine("AROcclusionManager"); |
|||
if (m_OcclusionManager == null) |
|||
{ |
|||
stringBuilder.AppendLine(" <null>"); |
|||
} |
|||
else if (!m_OcclusionManager.enabled) |
|||
{ |
|||
stringBuilder.AppendLine(" <disabled>"); |
|||
} |
|||
else |
|||
{ |
|||
stringBuilder.AppendLine(" Environment depth mode:"); |
|||
stringBuilder.AppendLine($" Requested: {m_OcclusionManager.requestedEnvironmentDepthMode}"); |
|||
stringBuilder.AppendLine($" Current: {m_OcclusionManager.currentEnvironmentDepthMode}"); |
|||
stringBuilder.AppendLine(" Human stencil mode:"); |
|||
stringBuilder.AppendLine($" Requested: {m_OcclusionManager.requestedHumanStencilMode}"); |
|||
stringBuilder.AppendLine($" Current: {m_OcclusionManager.currentHumanStencilMode}"); |
|||
stringBuilder.AppendLine(" Human depth mode:"); |
|||
stringBuilder.AppendLine($" Requested: {m_OcclusionManager.requestedHumanDepthMode}"); |
|||
stringBuilder.AppendLine($" Current: {m_OcclusionManager.currentHumanDepthMode}"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Log the given text to the screen if the image info UI is set. Otherwise, log the string to debug.
|
|||
/// </summary>
|
|||
/// <param name="text">The text string to log.</param>
|
|||
void LogText(string text) |
|||
{ |
|||
if (m_InfoText != null) |
|||
{ |
|||
m_InfoText.text = text; |
|||
} |
|||
else |
|||
{ |
|||
Debug.Log(text); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a8793e59c6aea4d1a91bfa0038a7e8e5 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3aae069bebee946a090ed6a756a1e77b |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!850595691 &4890085278179872738 |
|||
LightingSettings: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: ConfigurationChooserSettings |
|||
serializedVersion: 2 |
|||
m_GIWorkflowMode: 0 |
|||
m_EnableBakedLightmaps: 1 |
|||
m_EnableRealtimeLightmaps: 0 |
|||
m_RealtimeEnvironmentLighting: 1 |
|||
m_BounceScale: 1 |
|||
m_AlbedoBoost: 1 |
|||
m_IndirectOutputScale: 1 |
|||
m_UsingShadowmask: 1 |
|||
m_BakeBackend: 1 |
|||
m_LightmapMaxSize: 512 |
|||
m_BakeResolution: 10 |
|||
m_Padding: 2 |
|||
m_TextureCompression: 1 |
|||
m_AO: 0 |
|||
m_AOMaxDistance: 1 |
|||
m_CompAOExponent: 1 |
|||
m_CompAOExponentDirect: 0 |
|||
m_ExtractAO: 0 |
|||
m_MixedBakeMode: 2 |
|||
m_LightmapsBakeMode: 1 |
|||
m_FilterMode: 1 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_ExportTrainingData: 0 |
|||
m_TrainingDataDestination: TrainingData |
|||
m_RealtimeResolution: 2 |
|||
m_ForceWhiteAlbedo: 0 |
|||
m_ForceUpdates: 0 |
|||
m_FinalGather: 0 |
|||
m_FinalGatherRayCount: 256 |
|||
m_FinalGatherFiltering: 1 |
|||
m_PVRCulling: 1 |
|||
m_PVRSampling: 1 |
|||
m_PVRDirectSampleCount: 32 |
|||
m_PVRSampleCount: 256 |
|||
m_PVREnvironmentSampleCount: 256 |
|||
m_PVREnvironmentReferencePointCount: 2048 |
|||
m_LightProbeSampleCountMultiplier: 4 |
|||
m_PVRBounces: 2 |
|||
m_PVRRussianRouletteStartBounce: 2 |
|||
m_PVREnvironmentMIS: 0 |
|||
m_PVRFilteringMode: 2 |
|||
m_PVRDenoiserTypeDirect: 0 |
|||
m_PVRDenoiserTypeIndirect: 0 |
|||
m_PVRDenoiserTypeAO: 0 |
|||
m_PVRFilterTypeDirect: 0 |
|||
m_PVRFilterTypeIndirect: 0 |
|||
m_PVRFilterTypeAO: 0 |
|||
m_PVRFilteringGaussRadiusDirect: 1 |
|||
m_PVRFilteringGaussRadiusIndirect: 5 |
|||
m_PVRFilteringGaussRadiusAO: 2 |
|||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5 |
|||
m_PVRFilteringAtrousPositionSigmaIndirect: 2 |
|||
m_PVRFilteringAtrousPositionSigmaAO: 1 |
|
|||
fileFormatVersion: 2 |
|||
guid: 7353b45b3628640b39b11b7732d3e52f |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Assets/Scenes/Configurations/ConfigurationChooser.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
撰写
预览
正在加载...
取消
保存
Reference in new issue