您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
44 行
1.0 KiB
44 行
1.0 KiB
using System;
|
|
using UnityEditor;
|
|
|
|
namespace UnityEngine.MaterialGraph
|
|
{
|
|
[Serializable]
|
|
public class SerializableTexture
|
|
{
|
|
[SerializeField] private string m_SerializedTexture;
|
|
|
|
[Serializable]
|
|
private class TextureHelper
|
|
{
|
|
public Texture texture;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public Texture texture
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrEmpty(m_SerializedTexture))
|
|
return null;
|
|
|
|
var tex = new TextureHelper();
|
|
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, tex);
|
|
return tex.texture;
|
|
}
|
|
set
|
|
{
|
|
if (texture == value)
|
|
return;
|
|
|
|
var tex = new TextureHelper();
|
|
tex.texture = value;
|
|
m_SerializedTexture = EditorJsonUtility.ToJson(tex, true);
|
|
}
|
|
}
|
|
#else
|
|
public Texture defaultTexture {get; set; }
|
|
#endif
|
|
|
|
}
|
|
}
|