Dan
5 年前
当前提交
902bf007
共有 11 个文件被更改,包括 228 次插入 和 7 次删除
-
21Assets/Meshing/Scenes/Meshing.unity
-
6Packages/manifest.json
-
4ProjectSettings/EditorBuildSettings.asset
-
57Assets/Common/Scripts/CenterScreenHelper.cs
-
11Assets/Common/Scripts/CenterScreenHelper.cs.meta
-
71Assets/Common/Scripts/PlacementReticle.cs
-
11Assets/Common/Scripts/PlacementReticle.cs.meta
-
20Assets/Meshing/Scripts/ClassificationPlacementManager.cs
-
11Assets/Meshing/Scripts/ClassificationPlacementManager.cs.meta
-
15Assets/XR/Settings/AR Core Settings.asset
-
8Assets/XR/Settings/AR Core Settings.asset.meta
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.iOS; |
|||
|
|||
public class CenterScreenHelper : MonoBehaviour |
|||
{ |
|||
public static CenterScreenHelper Instance; |
|||
|
|||
float m_MidPointWidth; |
|||
float m_MidPointHeight; |
|||
Vector2 m_CenterScreenVert; |
|||
Vector2 m_CenterScreenHor; |
|||
ScreenOrientation m_CurrentOrientation; |
|||
float m_CurrentWidth; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_CurrentOrientation = Screen.orientation; |
|||
m_CurrentWidth = Screen.width; |
|||
m_MidPointWidth = Screen.width / 2; |
|||
m_MidPointHeight = Screen.height / 2; |
|||
|
|||
if (m_CurrentOrientation == ScreenOrientation.Landscape) |
|||
{ |
|||
m_CenterScreenVert = new Vector2(m_MidPointWidth, m_MidPointHeight); |
|||
m_CenterScreenHor = new Vector2(m_MidPointHeight, m_MidPointWidth); |
|||
} |
|||
else |
|||
{ |
|||
m_CenterScreenVert = new Vector2(m_MidPointHeight, m_MidPointWidth); |
|||
m_CenterScreenHor = new Vector2(m_MidPointWidth, m_MidPointHeight); |
|||
} |
|||
} |
|||
|
|||
public Vector2 GetCenterScreen() |
|||
{ |
|||
if (m_CurrentOrientation == ScreenOrientation.Landscape) |
|||
{ |
|||
return m_CenterScreenHor; |
|||
} |
|||
else |
|||
{ |
|||
return m_CenterScreenVert; |
|||
} |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if (Screen.width != m_CurrentWidth) |
|||
{ |
|||
m_CurrentWidth = Screen.width; |
|||
m_CurrentOrientation = Screen.orientation; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 33ad232cbb38441b9be19ff966ccc4a7 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.XR.ARFoundation; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
|
|||
public class PlacementReticle : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
bool m_SnapToMesh; |
|||
|
|||
[SerializeField] |
|||
ARRaycastManager m_RaycastManager; |
|||
|
|||
[SerializeField] |
|||
GameObject m_ReticlePrefab; |
|||
|
|||
GameObject m_SpawnedReticle; |
|||
CenterScreenHelper m_CenterScreen; |
|||
|
|||
static List<ARRaycastHit> s_Hits = new List<ARRaycastHit>(); |
|||
|
|||
TrackableType m_RaycastMask; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_CenterScreen = CenterScreenHelper.Instance; |
|||
if (m_SnapToMesh) |
|||
{ |
|||
m_RaycastMask = TrackableType.PlaneEstimated; |
|||
} |
|||
else |
|||
{ |
|||
m_RaycastMask = TrackableType.PlaneWithinPolygon; |
|||
} |
|||
|
|||
m_SpawnedReticle = Instantiate(m_ReticlePrefab); |
|||
m_SpawnedReticle.SetActive(false); |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if (m_RaycastManager) |
|||
{ |
|||
if (m_RaycastManager.Raycast(m_CenterScreen.GetCenterScreen(), s_Hits, m_RaycastMask)) |
|||
{ |
|||
Pose hitPose = s_Hits[0].pose; |
|||
m_SpawnedReticle.transform.SetPositionAndRotation(hitPose.position, hitPose.rotation); |
|||
m_SpawnedReticle.SetActive(true); |
|||
} |
|||
else |
|||
{ |
|||
m_SpawnedReticle.SetActive(false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public Transform GetReticlePosition() |
|||
{ |
|||
// if not active ie: not snapping to a plane return null
|
|||
if (!m_SpawnedReticle.activeSelf) |
|||
{ |
|||
return null; |
|||
} |
|||
else |
|||
{ |
|||
return m_SpawnedReticle.transform; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 19cb90afe530e4fa2940fd7ca763c5e3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class ClassificationPlacementManager : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
List<GameObject> m_FloorPrefabs; |
|||
|
|||
[SerializeField] |
|||
List<GameObject> m_TablePrefabs; |
|||
|
|||
[SerializeField] |
|||
List<GameObject> m_WallPrefabs; |
|||
|
|||
[SerializeField] |
|||
MeshClassificationManager m_ClassificationManager; |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 17f2541daf1b14188bcd16ec696d6815 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 9dae4501572e1418791be3e3bf1f7faa, type: 3} |
|||
m_Name: AR Core Settings |
|||
m_EditorClassIdentifier: |
|||
m_Requirement: 0 |
|
|||
fileFormatVersion: 2 |
|||
guid: 3c130c2e35c464faabda9a01bc854feb |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue