DanMillerDev
5 年前
当前提交
b4ee6635
共有 8 个文件被更改,包括 401 次插入 和 38 次删除
-
102Assets/Common/Fonts/Roboto-Medium SDF.asset
-
219Assets/UX/Scenes/UXManagerScene.unity
-
1ProjectSettings/GraphicsSettings.asset
-
3ProjectSettings/ProjectSettings.asset
-
4ProjectSettings/QualitySettings.asset
-
91Assets/UX/Scripts/ARUXReasonsManager.cs
-
11Assets/UX/Scripts/ARUXReasonsManager.cs.meta
-
8Assets/ARFoundationDemos.meta
102
Assets/Common/Fonts/Roboto-Medium SDF.asset
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System; |
|||
using TMPro; |
|||
using UnityEngine; |
|||
using UnityEngine.XR.ARFoundation; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
|
|||
public class ARUXReasonsManager : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
TMP_Text m_ReasonDisplayText; |
|||
|
|||
public TMP_Text reasonDisplayText |
|||
{ |
|||
get => m_ReasonDisplayText; |
|||
set => m_ReasonDisplayText = value; |
|||
} |
|||
|
|||
NotTrackingReason m_CurrentReason; |
|||
bool m_SessionTracking; |
|||
|
|||
const string k_InitRelocalText = "Session Initializing"; |
|||
const string k_MotionText = "Move the device slower"; |
|||
const string k_LightText = "Move to a brighter area"; |
|||
const string k_Features = "Not enough features"; |
|||
const string k_Unsupported = "AR is not supported on this device"; |
|||
const string k_None = "Error, not tracking"; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
ARSession.stateChanged += ARSessionOnstateChanged; |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if (!m_SessionTracking) |
|||
{ |
|||
m_CurrentReason = ARSession.notTrackingReason; |
|||
ShowReason(); |
|||
} |
|||
else |
|||
{ |
|||
if (m_ReasonDisplayText.gameObject.activeSelf) |
|||
{ |
|||
m_ReasonDisplayText.gameObject.SetActive(false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void ARSessionOnstateChanged(ARSessionStateChangedEventArgs obj) |
|||
{ |
|||
m_SessionTracking = obj.state == ARSessionState.SessionTracking ? true : false; |
|||
} |
|||
|
|||
void ShowReason() |
|||
{ |
|||
m_ReasonDisplayText.gameObject.SetActive(true); |
|||
m_ReasonDisplayText.text = ReasonString(); |
|||
} |
|||
|
|||
string ReasonString() |
|||
{ |
|||
string retVal = String.Empty; |
|||
|
|||
switch (m_CurrentReason) |
|||
{ |
|||
case NotTrackingReason.Initializing: |
|||
case NotTrackingReason.Relocalizing: |
|||
retVal = k_InitRelocalText; |
|||
break; |
|||
case NotTrackingReason.ExcessiveMotion: |
|||
retVal = k_MotionText; |
|||
break; |
|||
case NotTrackingReason.InsufficientLight: |
|||
retVal = k_LightText; |
|||
break; |
|||
case NotTrackingReason.InsufficientFeatures: |
|||
retVal = k_Features; |
|||
break; |
|||
case NotTrackingReason.Unsupported: |
|||
retVal = k_Unsupported; |
|||
break; |
|||
case NotTrackingReason.None: |
|||
retVal = k_None; |
|||
break; |
|||
} |
|||
|
|||
return retVal; |
|||
} |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8446de0774cd73441b1def01e5360fcc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: faeaceca7df854ff49277ef3f74f530f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue