initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Serializable]
|
||||
class SerializableMesh : ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField]
|
||||
string m_SerializedMesh;
|
||||
|
||||
[SerializeField]
|
||||
string m_Guid;
|
||||
|
||||
[NonSerialized]
|
||||
Mesh m_Mesh;
|
||||
|
||||
[Serializable]
|
||||
class MeshHelper
|
||||
{
|
||||
#pragma warning disable 649
|
||||
public Mesh mesh;
|
||||
#pragma warning restore 649
|
||||
}
|
||||
|
||||
public Mesh mesh
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m_SerializedMesh))
|
||||
{
|
||||
var textureHelper = new MeshHelper();
|
||||
EditorJsonUtility.FromJsonOverwrite(m_SerializedMesh, textureHelper);
|
||||
m_SerializedMesh = null;
|
||||
m_Guid = null;
|
||||
m_Mesh = textureHelper.mesh;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(m_Guid) && m_Mesh == null)
|
||||
{
|
||||
m_Mesh = AssetDatabase.LoadAssetAtPath<Mesh>(AssetDatabase.GUIDToAssetPath(m_Guid));
|
||||
m_Guid = null;
|
||||
}
|
||||
|
||||
return m_Mesh;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Mesh = value;
|
||||
m_Guid = null;
|
||||
m_SerializedMesh = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
m_SerializedMesh = EditorJsonUtility.ToJson(new MeshHelper { mesh = mesh }, false);
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue