浏览代码

Outside node control for UV slots

/main
Peter Bay Bastian 7 年前
当前提交
7b9315c4
共有 4 个文件被更改,包括 50 次插入0 次删除
  1. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/UVMaterialSlot.cs
  2. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
  3. 32
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/UVSlotControlView.cs
  4. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/UVSlotControlView.cs.meta

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/UVMaterialSlot.cs


using System;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{

: base(slotId, displayName, shaderOutputName, SlotType.Input, Vector2.zero, shaderStage, hidden)
{
this.channel = channel;
}
public override VisualElement InstantiateControl()
{
return new UVSlotControlView(this);
}
public override string GetDefaultValue(GenerationMode generationMode)

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss


margin-right: 0;
}
UVSlotControlView > EnumField {
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
width: 40;
}
.edge.fromMatrix4, .edge.fromMatrix3, .edge.fromMatrix2 {
edge-output-color: #8FC1DF;
}

32
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/UVSlotControlView.cs


using System;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
public class UVSlotControlView : VisualElement
{
UVMaterialSlot m_Slot;
public UVSlotControlView(UVMaterialSlot slot)
{
m_Slot = slot;
var enumField = new EnumField(slot.channel);
enumField.OnValueChanged(OnValueChanged);
Add(enumField);
}
void OnValueChanged(ChangeEvent<Enum> evt)
{
var channel = (UVChannel) evt.newValue;
if (channel != m_Slot.channel)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change UV Channel");
m_Slot.channel = channel;
if (m_Slot.owner.onModified != null)
m_Slot.owner.onModified(m_Slot.owner, ModificationScope.Graph);
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/UVSlotControlView.cs.meta


fileFormatVersion: 2
guid: f19b65893a414156825079dfc9a6dea3
timeCreated: 1509961226
正在加载...
取消
保存