|
|
|
|
|
|
[RequireComponent(typeof(ReflectionProbe))] |
|
|
|
public class HDAdditionalReflectionData : HDProbe, ISerializationCallbackReceiver |
|
|
|
{ |
|
|
|
const int currentVersion = 3; |
|
|
|
enum Version |
|
|
|
{ |
|
|
|
First, |
|
|
|
Second, |
|
|
|
HDProbeChild, |
|
|
|
UseInfluenceVolume, |
|
|
|
// Add new version here and they will automatically be the Current one
|
|
|
|
Max, |
|
|
|
Current = Max - 1 |
|
|
|
} |
|
|
|
|
|
|
|
const int currentVersion = (int)Version.Current; |
|
|
|
[SerializeField, FormerlySerializedAs("version")] |
|
|
|
int m_Version; |
|
|
|
|
|
|
|
|
|
|
#pragma warning restore 649 //never assigned
|
|
|
|
|
|
|
|
bool needMigrateToHDProbeChild = false; |
|
|
|
bool needMigrateToUseInfluenceVolume = false; |
|
|
|
|
|
|
|
public void OnBeforeSerialize() |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
if (m_Version != currentVersion) |
|
|
|
{ |
|
|
|
// Add here data migration code
|
|
|
|
if (m_Version < 2) |
|
|
|
// Add here data migration code that use other component
|
|
|
|
// Note impossible to access other component at deserialization time
|
|
|
|
if (m_Version < (int)Version.HDProbeChild) |
|
|
|
else if (m_Version < (int)Version.UseInfluenceVolume) |
|
|
|
{ |
|
|
|
needMigrateToUseInfluenceVolume = true; |
|
|
|
} |
|
|
|
{ |
|
|
|
if (m_Version < 3) |
|
|
|
{ |
|
|
|
MigrateToUseInfluenceVolume(); |
|
|
|
} |
|
|
|
{ |
|
|
|
// Add here data migration code that do not use other component
|
|
|
|
m_Version = currentVersion; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
{ |
|
|
|
if (needMigrateToHDProbeChild) |
|
|
|
MigrateToHDProbeChild(); |
|
|
|
if (needMigrateToUseInfluenceVolume) |
|
|
|
MigrateToUseInfluenceVolume(); |
|
|
|
} |
|
|
|
|
|
|
|
void MigrateToHDProbeChild() |
|
|
|
|
|
|
m_Version = 2; |
|
|
|
m_Version = (int)Version.HDProbeChild; |
|
|
|
needMigrateToHDProbeChild = false; |
|
|
|
OnAfterDeserialize(); //continue migrating if needed
|
|
|
|
} |
|
|
|
|
|
|
influenceVolume.boxSideFadePositive = boxSideFadePositive; |
|
|
|
influenceVolume.boxSideFadeNegative = boxSideFadeNegative; |
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
m_Version = (int)Version.HDProbeChild; |
|
|
|
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
|
|
|
|