您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
53 行
1.7 KiB
53 行
1.7 KiB
using System;
|
|
using UnityEditor.Graphing;
|
|
using UnityEditor.ShaderGraph.Drawing.Slots;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.UIElements;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Serializable]
|
|
public class ScreenPositionMaterialSlot : Vector4MaterialSlot, IMayRequireScreenPosition
|
|
{
|
|
[SerializeField]
|
|
ScreenSpaceType m_ScreenSpaceType;
|
|
|
|
public ScreenSpaceType screenSpaceType
|
|
{
|
|
get { return m_ScreenSpaceType; }
|
|
set { m_ScreenSpaceType = value; }
|
|
}
|
|
|
|
public ScreenPositionMaterialSlot()
|
|
{}
|
|
|
|
public ScreenPositionMaterialSlot(int slotId, string displayName, string shaderOutputName, ScreenSpaceType screenSpaceType,
|
|
ShaderStageCapability stageCapability = ShaderStageCapability.All, bool hidden = false)
|
|
: base(slotId, displayName, shaderOutputName, SlotType.Input, Vector3.zero, stageCapability, hidden: hidden)
|
|
{
|
|
this.screenSpaceType = screenSpaceType;
|
|
}
|
|
|
|
public override VisualElement InstantiateControl()
|
|
{
|
|
return new ScreenPositionSlotControlView(this);
|
|
}
|
|
|
|
public override string GetDefaultValue(GenerationMode generationMode)
|
|
{
|
|
return m_ScreenSpaceType.ToValueAsVariable();
|
|
}
|
|
|
|
public bool RequiresScreenPosition(ShaderStageCapability stageCapability)
|
|
{
|
|
return !isConnected;
|
|
}
|
|
|
|
public override void CopyValuesFrom(MaterialSlot foundSlot)
|
|
{
|
|
var slot = foundSlot as ScreenPositionMaterialSlot;
|
|
if (slot != null)
|
|
screenSpaceType = slot.screenSpaceType;
|
|
}
|
|
}
|
|
}
|