Tim Mowrer
4 年前
当前提交
6512c5b0
共有 6 个文件被更改,包括 8 次插入 和 378 次删除
-
242Assets/Scenes/ARFoundationMenu/Menu.unity
-
5Assets/Scripts/UX/ARSceneSelectUI.cs
-
8Assets/Scenes/UX.meta
-
120Assets/Scripts/UX/UIManager.cs
-
11Assets/Scripts/UX/UIManager.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 9a6de9d65f4d64509a5280cbe3d2d3af |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class UIManager : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
[Tooltip("The ARCameraManager which will produce frame events.")] |
|||
ARCameraManager m_CameraManager; |
|||
|
|||
/// <summary>
|
|||
/// Get or set the <c>ARCameraManager</c>.
|
|||
/// </summary>
|
|||
public ARCameraManager cameraManager |
|||
{ |
|||
get { return m_CameraManager; } |
|||
set |
|||
{ |
|||
if (m_CameraManager == value) |
|||
return; |
|||
|
|||
if (m_CameraManager != null) |
|||
m_CameraManager.frameReceived -= FrameChanged; |
|||
|
|||
m_CameraManager = value; |
|||
|
|||
if (m_CameraManager != null & enabled) |
|||
m_CameraManager.frameReceived += FrameChanged; |
|||
} |
|||
} |
|||
|
|||
const string k_FadeOffAnim = "FadeOff"; |
|||
const string k_FadeOnAnim = "FadeOn"; |
|||
|
|||
[SerializeField] |
|||
ARPlaneManager m_PlaneManager; |
|||
|
|||
public ARPlaneManager planeManager |
|||
{ |
|||
get { return m_PlaneManager; } |
|||
set { m_PlaneManager = value; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
Animator m_MoveDeviceAnimation; |
|||
|
|||
public Animator moveDeviceAnimation |
|||
{ |
|||
get { return m_MoveDeviceAnimation; } |
|||
set { m_MoveDeviceAnimation = value; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
Animator m_TapToPlaceAnimation; |
|||
|
|||
public Animator tapToPlaceAnimation |
|||
{ |
|||
get { return m_TapToPlaceAnimation; } |
|||
set { m_TapToPlaceAnimation = value; } |
|||
} |
|||
|
|||
static List<ARPlane> s_Planes = new List<ARPlane>(); |
|||
|
|||
bool m_ShowingTapToPlace = false; |
|||
|
|||
bool m_ShowingMoveDevice = true; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
if (m_CameraManager != null) |
|||
m_CameraManager.frameReceived += FrameChanged; |
|||
|
|||
PlaceMultipleObjectsOnPlane.onPlacedObject += PlacedObject; |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
if (m_CameraManager != null) |
|||
m_CameraManager.frameReceived -= FrameChanged; |
|||
|
|||
PlaceMultipleObjectsOnPlane.onPlacedObject -= PlacedObject; |
|||
} |
|||
|
|||
void FrameChanged(ARCameraFrameEventArgs args) |
|||
{ |
|||
if (PlanesFound() && m_ShowingMoveDevice) |
|||
{ |
|||
if (moveDeviceAnimation) |
|||
moveDeviceAnimation.SetTrigger(k_FadeOffAnim); |
|||
|
|||
if (tapToPlaceAnimation) |
|||
tapToPlaceAnimation.SetTrigger(k_FadeOnAnim); |
|||
|
|||
m_ShowingTapToPlace = true; |
|||
m_ShowingMoveDevice = false; |
|||
} |
|||
} |
|||
|
|||
bool PlanesFound() |
|||
{ |
|||
if (planeManager == null) |
|||
return false; |
|||
|
|||
return planeManager.trackables.count > 0; |
|||
} |
|||
|
|||
void PlacedObject() |
|||
{ |
|||
if (m_ShowingTapToPlace) |
|||
{ |
|||
if (tapToPlaceAnimation) |
|||
tapToPlaceAnimation.SetTrigger(k_FadeOffAnim); |
|||
|
|||
m_ShowingTapToPlace = false; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 162766bc881294f4b867bd32e1ef2fbe |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue