浏览代码

Fix non-modifiable cubemap data

/main
Matt Dean 7 年前
当前提交
c827f632
共有 2 个文件被更改,包括 35 次插入15 次删除
  1. 36
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableCubemap.cs
  2. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/PropertyCollector.cs

36
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableCubemap.cs


namespace UnityEditor.ShaderGraph
{
[Serializable]
public class SerializableCubemap
public class SerializableCubemap : ISerializationCallbackReceiver
{
[SerializeField]
private string m_SerializedCubemap;

public Cubemap cubemap;
}
Cubemap m_Cubemap;
if (string.IsNullOrEmpty(m_SerializedCubemap))
return null;
var cube = new CubemapHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedCubemap, cube);
return cube.cubemap;
if (m_Cubemap == null && !string.IsNullOrEmpty(m_SerializedCubemap))
{
var cube = new CubemapHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedCubemap, cube);
m_Cubemap = cube.cubemap;
m_SerializedCubemap = null;
}
return m_Cubemap;
set
{
if (cubemap == value)
return;
set { m_Cubemap = value; }
}
var cube = new CubemapHelper();
cube.cubemap = value;
m_SerializedCubemap = EditorJsonUtility.ToJson(cube, true);
}
public void OnBeforeSerialize()
{
var cube = new CubemapHelper { cubemap = cubemap };
m_SerializedCubemap = EditorJsonUtility.ToJson(cube, true);
}
public void OnAfterDeserialize()
{
}
}
}

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/PropertyCollector.cs


result.Add(textureInfo);
}
}
foreach (var prop in m_Properties.OfType<CubemapShaderProperty>())
{
if (prop.referenceName != null)
{
var textureInfo = new TextureInfo
{
name = prop.referenceName,
textureId = prop.value.cubemap != null ? prop.value.cubemap.GetInstanceID() : 0,
modifiable = prop.modifiable
};
result.Add(textureInfo);
}
}
return result;
}
}
正在加载...
取消
保存