浏览代码

Fix drag and drop support

/main
Peter Bay Bastian 6 年前
当前提交
55a261e5
共有 1 个文件被更改,包括 33 次插入1 次删除
  1. 34
      ShaderGraph/com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs

34
ShaderGraph/com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs


static bool ValidateObjectForDrop(Object obj)
{
return EditorUtility.IsPersistent(obj) && (obj is Texture2D || obj is Cubemap || obj is MaterialSubGraphAsset);
return EditorUtility.IsPersistent(obj) && (obj is Texture2D || obj is Cubemap || obj is MaterialSubGraphAsset || obj is Texture2DArray || obj is Texture3D);
}
static void OnDragUpdatedEvent(DragUpdatedEvent e)

if (inputslot != null)
inputslot.texture = texture2D;
}
var textureArray = obj as Texture2DArray;
if (textureArray != null)
{
graph.owner.RegisterCompleteObjectUndo("Drag Texture Array");
var property = new Texture2DArrayShaderProperty { displayName = textureArray.name, value = { textureArray = textureArray } };
graph.AddShaderProperty(property);
var node = new SampleTexture2DArrayNode();
var drawState = node.drawState;
drawState.position = new Rect(nodePosition, drawState.position.size);
node.drawState = drawState;
graph.AddNode(node);
var inputslot = node.FindSlot<Texture2DArrayInputMaterialSlot>(SampleTexture2DArrayNode.TextureInputId);
if (inputslot != null)
inputslot.textureArray = textureArray;
}
var texture3D = obj as Texture3D;
if (texture3D != null)
{
graph.owner.RegisterCompleteObjectUndo("Drag Texture 3D");
var property = new Texture3DShaderProperty { displayName = texture3D.name, value = { texture = texture3D } };
graph.AddShaderProperty(property);
var node = new SampleTexture3DNode();
var drawState = node.drawState;
drawState.position = new Rect(nodePosition, drawState.position.size);
node.drawState = drawState;
graph.AddNode(node);
var inputslot = node.FindSlot<Texture3DInputMaterialSlot>(SampleTexture3DNode.TextureInputId);
if (inputslot != null)
inputslot.texture = texture3D;
}
var cubemap = obj as Cubemap;

正在加载...
取消
保存