浏览代码

Merge pull request #1888 from Unity-Technologies/HDRP/fix/migration-process-at-creation-of-HDReflectionProbe

Hdrp/fix/migration process at creation of hd reflection probe
/hdrp-staging
GitHub 6 年前
当前提交
b8eff734
共有 3 个文件被更改,包括 50 次插入32 次删除
  1. 78
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  2. 2
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs

78
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[RequireComponent(typeof(ReflectionProbe))]
public class HDAdditionalReflectionData : HDProbe, ISerializationCallbackReceiver
public class HDAdditionalReflectionData : HDProbe
{
enum Version
{

data.weight = weight;
}
public void OnBeforeSerialize()
bool CheckMigrationRequirement()
}
//exit as quicker as possible
if (m_Version == (int)Version.Current)
return false;
public void OnAfterDeserialize()
{
if (m_Version != (int)Version.Current)
//it is mandatory to call them in order
//they can be grouped (without 'else' or not
if (m_Version < (int)Version.HDProbeChild)
{
needMigrateToHDProbeChild = true;
}
if (m_Version < (int)Version.UseInfluenceVolume)
// Add here data migration code that use other component
// Note impossible to access other component at deserialization time
if (m_Version < (int)Version.HDProbeChild)
{
needMigrateToHDProbeChild = true;
}
else if (m_Version < (int)Version.UseInfluenceVolume)
{
needMigrateToUseInfluenceVolume = true;
}
else if (m_Version < (int)Version.MergeEditors)
{
needMigrateToMergeEditors = true;
}
else
{
// Add here data migration code that do not use other component
m_Version = (int)Version.Current;
}
needMigrateToUseInfluenceVolume = true;
if (m_Version < (int)Version.MergeEditors)
{
needMigrateToMergeEditors = true;
}
//mandatory 'else' to only update version if other migrations done
else if (m_Version < (int)Version.Current)
{
m_Version = (int)Version.Current;
return false;
}
return true;
void OnEnable()
void ApplyMigration()
//it is mandatory to call them in order
if (needMigrateToHDProbeChild)
MigrateToHDProbeChild();
if (needMigrateToUseInfluenceVolume)

}
void Migrate()
{
//Must not be called at deserialisation time if require other component
while (CheckMigrationRequirement())
{
ApplyMigration();
}
}
internal override void Awake()
{
base.Awake();
//launch migration at creation too as m_Version could not have an
//existance in older version
Migrate();
}
void OnEnable()
{
ReflectionSystem.RegisterProbe(this);
}

refreshMode = reflectionProbe.refreshMode;
m_Version = (int)Version.HDProbeChild;
needMigrateToHDProbeChild = false;
OnAfterDeserialize(); //continue migrating if needed
}
void MigrateToUseInfluenceVolume()

#pragma warning restore CS0618 // Type or member is obsolete
m_Version = (int)Version.UseInfluenceVolume;
needMigrateToUseInfluenceVolume = false;
OnAfterDeserialize(); //continue migrating if needed
//Note: former editor parameters will be recreated as if non existent.
//User will lose parameters corresponding to non used mode between simplified and advanced

reflectionProbe.boxProjection = false;
m_Version = (int)Version.MergeEditors;
needMigrateToMergeEditors = false;
OnAfterDeserialize(); //continue migrating if needed
}
public override ReflectionProbeMode mode

2
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs


}
}
internal void Awake()
internal virtual void Awake()
{
if (influenceVolume == null)
influenceVolume = new InfluenceVolume();

2
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs


// Sphere
[SerializeField, FormerlySerializedAs("m_SphereBaseRadius")]
float m_SphereRadius = 1;
float m_SphereRadius = 3f;
[SerializeField, FormerlySerializedAs("m_SphereInfluenceFade")]
float m_SphereBlendDistance;
[SerializeField, FormerlySerializedAs("m_SphereInfluenceNormalFade")]

正在加载...
取消
保存