浏览代码

Add button to reload the ARSession

/3.1
Tim Mowrer 5 年前
当前提交
4157ab59
共有 9 个文件被更改,包括 1129 次插入1001 次删除
  1. 8
      Assets/Scenes/SimpleAR.meta
  2. 60
      Assets/Scenes/SimpleAR/ARSessionPrefab.prefab
  3. 7
      Assets/Scenes/SimpleAR/ARSessionPrefab.prefab.meta
  4. 42
      Assets/Scenes/SimpleAR/SessionReloader.cs
  5. 11
      Assets/Scenes/SimpleAR/SessionReloader.cs.meta
  6. 1001
      Assets/Scenes/SimpleAR/SimpleAR.unity
  7. 1001
      Assets/Scenes/SimpleAR.unity
  8. 0
      /Assets/Scenes/SimpleAR/SimpleAR.unity.meta

8
Assets/Scenes/SimpleAR.meta


fileFormatVersion: 2
guid: 86734efe1150d4800b3bceff47af8063
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

60
Assets/Scenes/SimpleAR/ARSessionPrefab.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3811591508773167257
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3811591508773167263}
- component: {fileID: 3811591508773167256}
- component: {fileID: 3811591508773167261}
m_Layer: 0
m_Name: AR Session
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3811591508773167263
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3811591508773167257}
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!114 &3811591508773167256
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3811591508773167257}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3859a92a05d4f5d418cb6ca605290e74, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AttemptUpdate: 1
m_MatchFrameRate: 1
--- !u!114 &3811591508773167261
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3811591508773167257}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fa850fbd5b8aded44846f96e35f1a9f5, type: 3}
m_Name:
m_EditorClassIdentifier:

7
Assets/Scenes/SimpleAR/ARSessionPrefab.prefab.meta


fileFormatVersion: 2
guid: 90290c13d4a3d46eea32be3d6a1a14c4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

42
Assets/Scenes/SimpleAR/SessionReloader.cs


using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
/// <summary>
/// Reloads the ARSession by first destroying the ARSession's GameObject
/// and then instantiating a new ARSession from a Prefab.
/// </summary>
public class SessionReloader : MonoBehaviour
{
public ARSession session;
public GameObject sessionPrefab;
public Button pauseButton;
public Button resumeButton;
public Button resetButton;
public void ReloadSession()
{
if (session != null)
{
StartCoroutine(DoReload());
}
}
IEnumerator DoReload()
{
Destroy(session.gameObject);
yield return null;
if (sessionPrefab != null)
{
session = Instantiate(sessionPrefab).GetComponent<ARSession>();
// Hook the buttons back up
resetButton.onClick.AddListener(session.Reset);
pauseButton.onClick.AddListener(() => { session.enabled = false; });
resumeButton.onClick.AddListener(() => { session.enabled = true; });
}
}
}

11
Assets/Scenes/SimpleAR/SessionReloader.cs.meta


fileFormatVersion: 2
guid: 68a46c818af354896be90ada1adb43c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1001
Assets/Scenes/SimpleAR/SimpleAR.unity
文件差异内容过多而无法显示
查看文件

1001
Assets/Scenes/SimpleAR.unity
文件差异内容过多而无法显示
查看文件

/Assets/Scenes/SimpleAR.unity.meta → /Assets/Scenes/SimpleAR/SimpleAR.unity.meta

正在加载...
取消
保存