浏览代码

Merge pull request #1691 from Unity-Technologies/IntVersionNumberForLightData

Changed version in HDAdditionalLightData from float to int
/main
GitHub 6 年前
当前提交
1fbde3ba
共有 3 个文件被更改,包括 30 次插入13 次删除
  1. 8
      com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs
  2. 8
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  3. 27
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs

8
com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs


[RequireComponent(typeof(Light))]
public class AdditionalShadowData : MonoBehaviour
{
[HideInInspector]
public float version = 1.0f;
// Currently m_Version is not used and produce a warning, remove these pragmas at the next version incrementation
#pragma warning disable 414
[SerializeField]
[UnityEngine.Serialization.FormerlySerializedAs("version")]
private int m_Version = 1;
#pragma warning restore 414
public const int DefaultShadowResolution = 512;

8
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


if (hdLightData != null)
hdLightData.UpdateAreaLightEmissiveMesh();
};
// If the light is disabled in the editor we force the light upgrade from his inspector
foreach (var additionalLightData in m_AdditionalLightDatas)
additionalLightData.UpgradeLight();
}
public override void OnInspectorGUI()

if (m_UpdateAreaLightEmissiveMeshComponents)
UpdateAreaLightEmissiveMeshComponents();
// If the light is disabled in the editor we force the light upgrade from his inspector
foreach (var additionalLightData in m_AdditionalLightDatas)
additionalLightData.UpgradeLight();
}
void DrawFoldout(SerializedProperty foldoutProperty, string title, Action func)

27
com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs


[ExecuteInEditMode]
public class HDAdditionalLightData : MonoBehaviour, ISerializationCallbackReceiver
{
public const float currentVersion = 1.1f;
private const int currentVersion = 2;
[HideInInspector]
[HideInInspector, SerializeField]
public float version = currentVersion;
[System.Obsolete("version is deprecated, use m_Version instead")]
private float version = currentVersion;
// Currently m_Version is not used and produce a warning, remove these pragmas at the next version incrementation
#pragma warning disable 414
[SerializeField]
private int m_Version = currentVersion;
#pragma warning restore 414
// To be able to have correct default values for our lights and to also control the conversion of intensity from the light editor (so it is compatible with GI)
// we add intensity (for each type of light we want to manage).

public void OnAfterDeserialize()
{
// If we are deserializing an old version, convert the light intensity to the new system
// Note: the field version is deprecated but we keep it for retro-compatibility reasons, you should use m_Version instead
#pragma warning disable 0618
#pragma warning restore 0618
{
// Note: We can't access to the light component in OnAfterSerialize as it is not init() yet,
// so instead we use a boolean to do the upgrade in OnEnable().

public void UpgradeLight()
{
// Disable the warning generated by deprecated fields (areaIntensity, directionalIntensity, ...)
#pragma warning disable 0618
// If we are deserializing an old version, convert the light intensity to the new system
// Pragma to disable the warning got by using deprecated properties (areaIntensity, directionalIntensity, ...)
#pragma warning disable 0618
switch (lightTypeExtent)
{
case LightTypeExtent.Punctual:

intensity = areaIntensity;
break;
}
#pragma warning restore 0618
needsIntensityUpdate_1_0 = false;
m_Version = currentVersion;
#pragma warning restore 0618
}
}
}
正在加载...
取消
保存