浏览代码

code clean up with center screen helper, added additional placement prefab for fog scene

/ARCoreShaderFog
Dan 4 年前
当前提交
6ae3274b
共有 7 个文件被更改,包括 141 次插入34 次删除
  1. 16
      Assets/Common/Scripts/CenterScreenHelper.cs
  2. 9
      Assets/Common/Scripts/PlacementReticle.cs
  3. 4
      Assets/Meshing/Scripts/MeshClassificationManager.cs
  4. 2
      Assets/Shaders/Scenes/Fog.unity
  5. 11
      ProjectSettings/EditorBuildSettings.asset
  6. 126
      Assets/Common/Prefabs/SphereObject_NoShadow.prefab
  7. 7
      Assets/Common/Prefabs/SphereObject_NoShadow.prefab.meta

16
Assets/Common/Scripts/CenterScreenHelper.cs


{
Destroy(this);
}
m_CurrentOrientation = Screen.orientation;
m_CurrentWidth = Screen.width;
m_MidPointWidth = Screen.width / 2;

{
m_CenterScreenVert = new Vector2(m_MidPointWidth, m_MidPointHeight);
m_CenterScreenHor = new Vector2(m_MidPointHeight, m_MidPointWidth);
if (m_CurrentOrientation == ScreenOrientation.Landscape)
{
return m_CenterScreenHor;
}
else
{
return m_CenterScreenVert;
}
}
void Update()
{
return m_CurrentOrientation == ScreenOrientation.Landscape ? m_CenterScreenHor : m_CenterScreenVert;
}
}

9
Assets/Common/Scripts/PlacementReticle.cs


static List<ARRaycastHit> s_Hits = new List<ARRaycastHit>();
const float k_MinScaleDistance = 0.0f;
const float k_MaxScaleDistance = 1.0f;
const float k_ScaleMod = 1.0f;
void Start()
{

if (m_DistanceScale)
{
m_CurrentDistance = Vector3.Distance(m_SpawnedReticle.transform.position, m_CameraTransform.position);
m_CurrentNormalizedDistance = ((Mathf.Abs(m_CurrentDistance - k_MinScaleDistance)) / (k_MaxScaleDistance - k_MinScaleDistance))+1;
m_CurrentNormalizedDistance = ((Mathf.Abs(m_CurrentDistance - k_MinScaleDistance)) / (k_MaxScaleDistance - k_MinScaleDistance))+k_ScaleMod;
m_SpawnedReticle.transform.localScale = new Vector3(m_CurrentNormalizedDistance, m_CurrentNormalizedDistance, m_CurrentNormalizedDistance);
}
}

// if not active ie: not snapping to a plane return null
if (!m_SpawnedReticle.activeSelf)
{
return null;
}
return m_SpawnedReticle.transform;
}
}

4
Assets/Meshing/Scripts/MeshClassificationManager.cs


set => m_MainCamera = value;
}
Vector2 m_ScreenCenter;
RaycastHit m_Hit;
TrackableId m_CurrentTrackableID;
XRMeshSubsystem m_MeshSubsystem;

void OnEnable()
{
m_ScreenCenter = new Vector2(Screen.width / 2, Screen.height / 2);
m_MeshSubsystem = m_MeshManager.subsystem;
m_MeshSubsystem.SetClassificationEnabled(true);

void Update()
{
if (Physics.Raycast(m_MainCamera.ScreenPointToRay(m_ScreenCenter), out m_Hit))
if (Physics.Raycast(m_MainCamera.ScreenPointToRay(CenterScreenHelper.Instance.GetCenterScreen()), out m_Hit))
{
SetCurrentClassification(ExtractTrackableId(m_Hit.transform.name), m_Hit.triangleIndex);
m_CurrentClassificationLabel.text = GetClassificationName(m_CurrentClassification);

2
Assets/Shaders/Scenes/Fog.unity


m_Script: {fileID: 11500000, guid: 446fc7fee4cf2ad4daa02222a84869c4, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PlacedPrefab: {fileID: 6562802905340916462, guid: f87dd2359ba946141af737fcd7366b3a,
m_PlacedPrefab: {fileID: 6562802905340916462, guid: ac267a3a72f244ea9b2bd9b1552e4bd6,
type: 3}
m_MaxNumberOfObjectsToPlace: 1
--- !u!114 &1614374573

11
ProjectSettings/EditorBuildSettings.asset


EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 0
path: Assets/ImageTracking/Scenes/ImageTracking.unity
guid: 90c9c5e58ea6f4125979d49ff7533aee
- enabled: 0
path: Assets/UX/Scenes/UXManagerScene.unity
guid: 5d9539f4c7ee5c74c85a038c90cb6e1b
- enabled: 1
path: Assets/Meshing/Scenes/Meshing.unity
guid: d5ebb81bb19834855bb7ca490ab73fbf
m_Scenes: []
m_configObjects:
UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: 6390cd816397648a5b1cc5fc4723e0ba,
type: 2}

126
Assets/Common/Prefabs/SphereObject_NoShadow.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6562802905340916462
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5441817961917878163}
m_Layer: 0
m_Name: SphereObject_NoShadow
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5441817961917878163
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6562802905340916462}
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:
- {fileID: 8744959069573895519}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &9021161848136789997
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8744959069573895519}
- component: {fileID: 1503935867054168130}
- component: {fileID: 7733701389298627304}
- component: {fileID: 2362380223743076767}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8744959069573895519
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9021161848136789997}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.125, z: 0}
m_LocalScale: {x: 0.25, y: 0.25, z: 0.25}
m_Children: []
m_Father: {fileID: 5441817961917878163}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1503935867054168130
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9021161848136789997}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &7733701389298627304
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9021161848136789997}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d539f3f4f0dcd46998c9a55cd41a1c56, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &2362380223743076767
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9021161848136789997}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}

7
Assets/Common/Prefabs/SphereObject_NoShadow.prefab.meta


fileFormatVersion: 2
guid: ac267a3a72f244ea9b2bd9b1552e4bd6
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存