浏览代码

Merge branch 'master' of github.com:Unity-Technologies/arfoundation-samples

/1.5-preview
Tim Mowrer 6 年前
当前提交
776fc940
共有 2 个文件被更改,包括 27 次插入44 次删除
  1. 19
      Assets/Scenes/SampleScene.unity
  2. 52
      Assets/Scripts/PlaceOnPlane.cs

19
Assets/Scenes/SampleScene.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.49641287, b: 0.5748173, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 25.3
near clip plane: 0.1
far clip plane: 20
field of view: 60
m_Depth: -1
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295

m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 0
m_AllowMSAA: 1
m_ForceIntoRT: 1
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022

m_Name:
m_EditorClassIdentifier:
m_LightEstimation: 0
m_TryToInstallUpdateIfNeeded: 1
m_AttemptUpdate: 1
--- !u!4 &427002220
Transform:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
m_Camera: {fileID: 282840813}
m_Scale: 1
--- !u!4 &1335839535
Transform:
m_ObjectHideFlags: 0

m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -18}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 282840814}

52
Assets/Scripts/PlaceOnPlane.cs


get { return m_PlacedPrefab; }
set { m_PlacedPrefab = value; }
}
public GameObject placedObject { get; private set; }
public GameObject spawnedObject { get; private set; }
ARSessionOrigin m_SessionOrigin;
static List<ARRaycastHit> s_Hits = new List<ARRaycastHit>();
void Awake()
{
m_SessionOrigin = GetComponent<ARSessionOrigin>();

{
if (Input.touchCount == 0)
return;
var touch = Input.GetTouch(0);
var hits = s_RaycastHits;
if (!m_SessionOrigin.Raycast(touch.position, hits, TrackableType.PlaneWithinPolygon))
return;
placementHit = hits[0];
}
ARSessionOrigin m_SessionOrigin;
ARRaycastHit m_PlacementHit;
ARRaycastHit placementHit
{
get { return m_PlacementHit; }
set
if (Input.touchCount > 0)
m_PlacementHit = value;
Touch touch = Input.GetTouch(0);
if (placedObject == null && m_PlacedPrefab != null)
if (m_SessionOrigin.Raycast(touch.position, s_Hits, TrackableType.PlaneWithinPolygon))
placedObject = Instantiate(m_PlacedPrefab);
}
Pose hitPose = s_Hits[0].pose;
if (placedObject != null)
{
var pose = m_PlacementHit.pose;
placedObject.transform.position = pose.position;
placedObject.transform.rotation = pose.rotation;
if (spawnedObject == null)
{
spawnedObject = Instantiate(m_PlacedPrefab, hitPose.position, hitPose.rotation);
}
else
{
spawnedObject.transform.position = hitPose.position;
}
List<ARRaycastHit> s_RaycastHits = new List<ARRaycastHit>();
}
正在加载...
取消
保存