您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
75 行
2.3 KiB
75 行
2.3 KiB
using System.Collections.Generic;
|
|
using UnityEditor.ShaderGraph.Drawing.Controls;
|
|
using UnityEngine;
|
|
using UnityEditor.Graphing;
|
|
using UnityEditor.ShaderGraph.Internal;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Title("Input", "Texture", "Cubemap Asset")]
|
|
class CubemapAssetNode : AbstractMaterialNode, IPropertyFromNode
|
|
{
|
|
public const int OutputSlotId = 0;
|
|
|
|
const string kOutputSlotName = "Out";
|
|
|
|
public CubemapAssetNode()
|
|
{
|
|
name = "Cubemap Asset";
|
|
UpdateNodeAfterDeserialization();
|
|
}
|
|
|
|
|
|
public sealed override void UpdateNodeAfterDeserialization()
|
|
{
|
|
AddSlot(new CubemapMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
|
|
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
|
|
}
|
|
|
|
[SerializeField]
|
|
private SerializableCubemap m_Cubemap = new SerializableCubemap();
|
|
|
|
[CubemapControl("")]
|
|
public Cubemap cubemap
|
|
{
|
|
get { return m_Cubemap.cubemap; }
|
|
set
|
|
{
|
|
if (m_Cubemap.cubemap == value)
|
|
return;
|
|
m_Cubemap.cubemap = value;
|
|
Dirty(ModificationScope.Node);
|
|
}
|
|
}
|
|
|
|
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
|
|
{
|
|
properties.AddShaderProperty(new CubemapShaderProperty()
|
|
{
|
|
overrideReferenceName = GetVariableNameForSlot(OutputSlotId),
|
|
generatePropertyBlock = true,
|
|
value = m_Cubemap,
|
|
modifiable = false
|
|
});
|
|
}
|
|
|
|
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
|
|
{
|
|
properties.Add(new PreviewProperty(PropertyType.Cubemap)
|
|
{
|
|
name = GetVariableNameForSlot(OutputSlotId),
|
|
cubemapValue = cubemap
|
|
});
|
|
}
|
|
|
|
public AbstractShaderProperty AsShaderProperty()
|
|
{
|
|
var prop = new CubemapShaderProperty { value = m_Cubemap };
|
|
if (cubemap != null)
|
|
prop.displayName = cubemap.name;
|
|
return prop;
|
|
}
|
|
|
|
public int outputSlotId { get { return OutputSlotId; } }
|
|
}
|
|
}
|