|
|
|
|
|
|
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 |
|
|
|