浏览代码

wip meshing demo, reticle for placement, Object handler

/main
Dan 4 年前
当前提交
902bf007
共有 11 个文件被更改,包括 228 次插入7 次删除
  1. 21
      Assets/Meshing/Scenes/Meshing.unity
  2. 6
      Packages/manifest.json
  3. 4
      ProjectSettings/EditorBuildSettings.asset
  4. 57
      Assets/Common/Scripts/CenterScreenHelper.cs
  5. 11
      Assets/Common/Scripts/CenterScreenHelper.cs.meta
  6. 71
      Assets/Common/Scripts/PlacementReticle.cs
  7. 11
      Assets/Common/Scripts/PlacementReticle.cs.meta
  8. 20
      Assets/Meshing/Scripts/ClassificationPlacementManager.cs
  9. 11
      Assets/Meshing/Scripts/ClassificationPlacementManager.cs.meta
  10. 15
      Assets/XR/Settings/AR Core Settings.asset
  11. 8
      Assets/XR/Settings/AR Core Settings.asset.meta

21
Assets/Meshing/Scenes/Meshing.unity


- component: {fileID: 121553691}
- component: {fileID: 121553694}
- component: {fileID: 121553696}
- component: {fileID: 121553695}
m_Layer: 0
m_Name: AR Session Origin
m_TagString: Untagged

m_Name:
m_EditorClassIdentifier:
m_RaycastPrefab: {fileID: 0}
--- !u!114 &121553695
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 121553690}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 73a025b51106444e18fb408fde19ac53, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AutomaticPlacement: 1
m_EnvironmentTextureFilterMode: 2
m_EnvironmentTextureHDR: 1
m_DebugPrefab: {fileID: 0}
--- !u!114 &121553696
MonoBehaviour:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 121553690}
m_Enabled: 0
m_Enabled: 1
m_ProbeManager: {fileID: 0}
m_ProbeManager: {fileID: 121553695}
m_Camera: {fileID: 1823173797}
--- !u!1 &438185557
GameObject:

6
Packages/manifest.json


"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.2.10",
"com.unity.ugui": "1.0.0",
"com.unity.xr.arcore": "4.0.0-preview.3",
"com.unity.xr.arfoundation": "4.0.0-preview.3",
"com.unity.xr.arkit": "4.0.0-preview.3",
"com.unity.xr.arcore": "4.1.0-preview.2",
"com.unity.xr.arfoundation": "4.1.0-preview.2",
"com.unity.xr.arkit": "file:/Users/danielmi/Downloads/package",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

4
ProjectSettings/EditorBuildSettings.asset


path: Assets/Meshing/Scenes/Meshing.unity
guid: d5ebb81bb19834855bb7ca490ab73fbf
m_configObjects:
com.unity.xr.arcore.PlayerSettings: {fileID: 11400000, guid: 548641ba2e111fb4bb0267a9742ca02c,
UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: 3c130c2e35c464faabda9a01bc854feb,
com.unity.xr.arkit.PlayerSettings: {fileID: 11400000, guid: aa5435beafbd54df081a4bc6c3fb48d1,
com.unity.xr.arcore.PlayerSettings: {fileID: 11400000, guid: 548641ba2e111fb4bb0267a9742ca02c,
type: 2}
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 5c86decb01f9d6b46a50ce486fba0042,
type: 2}

57
Assets/Common/Scripts/CenterScreenHelper.cs


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;
}
}
}

11
Assets/Common/Scripts/CenterScreenHelper.cs.meta


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

71
Assets/Common/Scripts/PlacementReticle.cs


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;
}
}
}

11
Assets/Common/Scripts/PlacementReticle.cs.meta


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

20
Assets/Meshing/Scripts/ClassificationPlacementManager.cs


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;
}

11
Assets/Meshing/Scripts/ClassificationPlacementManager.cs.meta


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

15
Assets/XR/Settings/AR Core Settings.asset


%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

8
Assets/XR/Settings/AR Core Settings.asset.meta


fileFormatVersion: 2
guid: 3c130c2e35c464faabda9a01bc854feb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存