浏览代码

updated README and comments

/4.1
Shan Jiang 4 年前
当前提交
4b465207
共有 6 个文件被更改,包括 11 次插入124 次删除
  1. 82
      Assets/Scenes/LightEstimation/HDRLightEstimation.unity
  2. 6
      Assets/Scripts/BasicLightEstimation.cs
  3. 4
      Assets/Scripts/BasicLightEstimationUI.cs
  4. 6
      Assets/Scripts/HDRLightEstimation.cs
  5. 31
      Assets/Scripts/HDRLightEstimationUI.cs
  6. 6
      README.md

82
Assets/Scenes/LightEstimation/HDRLightEstimation.unity


m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &326400021
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 326400022}
- component: {fileID: 326400024}
- component: {fileID: 326400023}
m_Layer: 5
m_Name: ModeSupported
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &326400022
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 326400021}
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: 1633939411}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 125, y: -1000}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &326400023
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 326400021}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 35
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 49
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 1
m_VerticalOverflow: 1
m_LineSpacing: 1
m_Text: Current Mode is supported
--- !u!222 &326400024
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 326400021}
m_CullTransparentMesh: 0
--- !u!1 &400734518
GameObject:
m_ObjectHideFlags: 0

m_MainLightIntensityLumens: {fileID: 1373858106}
m_MainLightColor: {fileID: 639485727}
m_SphericalHarmonicsText: {fileID: 1377107162}
m_ModeSupportedText: {fileID: 326400023}
m_ModeSupportedText: {fileID: 0}
--- !u!114 &1195718495
MonoBehaviour:
m_ObjectHideFlags: 0

- {fileID: 1373858105}
- {fileID: 639485726}
- {fileID: 1377107161}
- {fileID: 326400022}
- {fileID: 1595064836}
m_Father: {fileID: 0}
m_RootOrder: 4

6
Assets/Scripts/BasicLightEstimation.cs


namespace UnityEngine.XR.ARFoundation.Samples
{
/// <summary>
/// A component that can be used to access the most
/// recently received light estimation information
/// for the physical environment as observed by an
/// AR device.
/// A component that can be used to access the most recently received basic light estimation information
/// for the physical environment as observed by an AR device.
/// </summary>
[RequireComponent(typeof(Light))]
public class BasicLightEstimation : MonoBehaviour

4
Assets/Scripts/BasicLightEstimationUI.cs


namespace UnityEngine.XR.ARFoundation.Samples
{
/// <summary>
/// A simple UI controller to display light estimation information.
/// A simple UI controller to display basic light estimation information.
/// </summary>
[RequireComponent(typeof(BasicLightEstimation))]
public class BasicLightEstimationUI : MonoBehaviour

Text m_AmbientColorText;
/// <summary>
/// The UI Text element used to display the estimated color temperature in the scene.
/// The UI Text element used to display the estimated ambient color in the scene.
/// </summary>
public Text ambientColorText
{

6
Assets/Scripts/HDRLightEstimation.cs


namespace UnityEngine.XR.ARFoundation.Samples
{
/// <summary>
/// A component that can be used to access the most
/// recently received light estimation information
/// for the physical environment as observed by an
/// AR device.
/// A component that can be used to access the most recently received HDR light estimation information
/// for the physical environment as observed by an AR device.
/// </summary>
[RequireComponent(typeof(Light))]
public class HDRLightEstimation : MonoBehaviour

31
Assets/Scripts/HDRLightEstimationUI.cs


namespace UnityEngine.XR.ARFoundation.Samples
{
/// <summary>
/// A simple UI controller to display light estimation information.
/// A simple UI controller to display HDR light estimation information.
/// </summary>
[RequireComponent(typeof(HDRLightEstimation))]
public class HDRLightEstimationUI : MonoBehaviour

}
StringBuilder m_SphericalHarmonicsStringBuilder = new StringBuilder("");
[Tooltip("The UI Text element used to display whether the requested light estimation mode is supported on the device.")]
[SerializeField]
Text m_ModeSupportedText;
public Text modeSupportedText
{
get => m_ModeSupportedText;
set => m_ModeSupportedText = value;
}
m_cameraManager = m_HDRLightEstimation.cameraManager;
}
void Update()

SetUIValue(m_HDRLightEstimation.mainLightIntensityLumens, mainLightIntensityLumens);
SetSphericalHarmonicsUIValue(m_HDRLightEstimation.sphericalHarmonics, ambientSphericalHarmonicsText);
SetModeSupportedUIValue(m_cameraManager.requestedFacingDirection);
}
void SetSphericalHarmonicsUIValue(SphericalHarmonicsL2? maybeAmbientSphericalHarmonics, Text text)

text.text = displayValue.HasValue ? displayValue.Value.ToString(): k_UnavailableText;
}
void SetModeSupportedUIValue(CameraFacingDirection direction)
{
#if UNITY_IOS
if (direction == CameraFacingDirection.World)
{
m_ModeSupportedText.text = "The requested world facing and HDR Mode is NOT supported on iOS.";
}
#endif
#if UNITY_ANDROID
if (direction == CameraFacingDirection.User)
{
m_ModeSupportedText.text = "The requested user facing and HDR Mode is NOT supported on Android.";
}
#endif
}
ARCameraManager m_cameraManager;
}
}

6
README.md


## LightEstimation
### BasicLightEstimation
Demonstrates basic light estimation information from the camera frame. You should see values for "Ambient Intensity" and "Ambient Color" on screen.
Demonstrates basic light estimation information from the camera frame. You should see values for "Ambient Intensity" and "Ambient Color" on screen. The relevant script is [`BasicLightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scripts/BasicLightEstimation.cs) script.
This sample attempts to read HDR lighting information. You should see values for "Main Light Direction", "Main Light Intensity Lumens", "Main Light Color", and "Spherical Harmonics". Most devices only support a subset of these 4, so some will be listed as "unavailable."
This sample attempts to read HDR lighting information. You should see values for "Main Light Direction", "Main Light Intensity Lumens", "Main Light Color", and "Spherical Harmonics". Most devices only support a subset of these 4, so some will be listed as "unavailable." The relevant script is [`HDRLightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scripts/HDRLightEstimation.cs) script.
The relevant scripts are on the "Directional Light" GameObject, including the [`LightEstimation.cs`](https://github.com/Unity-Technologies/arfoundation-samples/blob/master/Assets/Scripts/LightEstimation.cs) script.
When using `HDRLightEstimation`, the sample will automatically pick the supported camera facing direction for you, for example `World` on Android and `User` on iOS, so it does not matter which you select in `ARCameraManager.cs`.
## Anchors

正在加载...
取消
保存