Firstborn/Library/PackageCache/com.unity.shadergraph@12.1.8/Editor/Data/Graphs/SerializableGuid.cs
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

45 lines
994 B
C#

using System;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Serializable]
class SerializableGuid : ISerializationCallbackReceiver
{
public SerializableGuid()
{
m_Guid = Guid.NewGuid();
}
public SerializableGuid(Guid guid)
{
m_Guid = guid;
}
[NonSerialized]
private Guid m_Guid;
[SerializeField]
private string m_GuidSerialized;
public Guid guid
{
get { return m_Guid; }
internal set { m_Guid = value; } // allow id to be overwritten when necessary
}
public virtual void OnBeforeSerialize()
{
m_GuidSerialized = m_Guid.ToString();
}
public virtual void OnAfterDeserialize()
{
if (!string.IsNullOrEmpty(m_GuidSerialized))
m_Guid = new Guid(m_GuidSerialized);
else
m_Guid = Guid.NewGuid();
}
}
}