浏览代码

Add copy function in IShaderProperty, and implement this in all property classes

/main
Jens Holm 7 年前
当前提交
74c313c2
共有 16 个文件被更改,包括 104 次插入48 次删除
  1. 1
      com.unity.shadergraph/Editor/Data/Graphs/AbstractShaderProperty.cs
  2. 8
      com.unity.shadergraph/Editor/Data/Graphs/BooleanShaderProperty.cs
  3. 8
      com.unity.shadergraph/Editor/Data/Graphs/ColorShaderProperty.cs
  4. 8
      com.unity.shadergraph/Editor/Data/Graphs/CubemapShaderProperty.cs
  5. 1
      com.unity.shadergraph/Editor/Data/Graphs/IShaderProperty.cs
  6. 10
      com.unity.shadergraph/Editor/Data/Graphs/Matrix2ShaderProperty.cs
  7. 8
      com.unity.shadergraph/Editor/Data/Graphs/Matrix3ShaderProperty.cs
  8. 8
      com.unity.shadergraph/Editor/Data/Graphs/Matrix4ShaderProperty.cs
  9. 2
      com.unity.shadergraph/Editor/Data/Graphs/MatrixShaderProperty.cs
  10. 10
      com.unity.shadergraph/Editor/Data/Graphs/SamplerStateShaderProperty.cs
  11. 10
      com.unity.shadergraph/Editor/Data/Graphs/TextureShaderProperty.cs
  12. 8
      com.unity.shadergraph/Editor/Data/Graphs/Vector1ShaderProperty.cs
  13. 8
      com.unity.shadergraph/Editor/Data/Graphs/Vector2ShaderProperty.cs
  14. 8
      com.unity.shadergraph/Editor/Data/Graphs/Vector3ShaderProperty.cs
  15. 8
      com.unity.shadergraph/Editor/Data/Graphs/Vector4ShaderProperty.cs
  16. 46
      com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs

1
com.unity.shadergraph/Editor/Data/Graphs/AbstractShaderProperty.cs


public abstract PreviewProperty GetPreviewMaterialProperty();
public abstract INode ToConcreteNode();
public abstract IShaderProperty Copy();
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/BooleanShaderProperty.cs


{
return new BooleanNode { value = new Toggle(value) };
}
public override IShaderProperty Copy()
{
var copied = new BooleanShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/ColorShaderProperty.cs


{
return new ColorNode { color = new ColorNode.Color(value, colorMode) };
}
public override IShaderProperty Copy()
{
var copied = new ColorShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/CubemapShaderProperty.cs


{
return new CubemapAssetNode { cubemap = value.cubemap };
}
public override IShaderProperty Copy()
{
var copied = new CubemapShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

1
com.unity.shadergraph/Editor/Data/Graphs/IShaderProperty.cs


PreviewProperty GetPreviewMaterialProperty();
INode ToConcreteNode();
IShaderProperty Copy();
}
}

10
com.unity.shadergraph/Editor/Data/Graphs/Matrix2ShaderProperty.cs


row0 = new Vector2(value.m00, value.m01),
row1 = new Vector2(value.m10, value.m11)
};
}
}
public override IShaderProperty Copy()
{
var copied = new Matrix2ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/Matrix3ShaderProperty.cs


row2 = new Vector3(value.m20, value.m21, value.m22)
};
}
public override IShaderProperty Copy()
{
var copied = new Matrix3ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/Matrix4ShaderProperty.cs


row3 = new Vector4(value.m30, value.m31, value.m32, value.m33)
};
}
public override IShaderProperty Copy()
{
var copied = new Matrix4ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

2
com.unity.shadergraph/Editor/Data/Graphs/MatrixShaderProperty.cs


public override PreviewProperty GetPreviewMaterialProperty()
{
return default(PreviewProperty);
}
}
}
}

10
com.unity.shadergraph/Editor/Data/Graphs/SamplerStateShaderProperty.cs


using System;
using System;
using UnityEditor.Graphing;
using UnityEngine;

public override INode ToConcreteNode()
{
return new SamplerStateNode();
}
public override IShaderProperty Copy()
{
var copied = new SamplerStateShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

10
com.unity.shadergraph/Editor/Data/Graphs/TextureShaderProperty.cs


using System;
using System;
using System.Text;
using UnityEditor.Graphing;
using UnityEngine;

public override INode ToConcreteNode()
{
return new Texture2DAssetNode { texture = value.texture };
}
public override IShaderProperty Copy()
{
var copied = new TextureShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/Vector1ShaderProperty.cs


return node;
}
}
public override IShaderProperty Copy()
{
var copied = new Vector1ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/Vector2ShaderProperty.cs


node.FindInputSlot<Vector1MaterialSlot>(Vector2Node.InputSlotYId).value = value.y;
return node;
}
public override IShaderProperty Copy()
{
var copied = new Vector2ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/Vector3ShaderProperty.cs


node.FindInputSlot<Vector1MaterialSlot>(Vector3Node.InputSlotZId).value = value.z;
return node;
}
public override IShaderProperty Copy()
{
var copied = new Vector3ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

8
com.unity.shadergraph/Editor/Data/Graphs/Vector4ShaderProperty.cs


node.FindInputSlot<Vector1MaterialSlot>(Vector4Node.InputSlotWId).value = value.w;
return node;
}
public override IShaderProperty Copy()
{
var copied = new Vector4ShaderProperty();
copied.displayName = displayName;
copied.value = value;
return copied;
}
}
}

46
com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs


if (copyGraph == null)
return;
// Make new properties from the copied graph
IShaderProperty copiedProperty = null;
if (property is Vector1ShaderProperty)
{
copiedProperty = new Vector1ShaderProperty();
(copiedProperty as Vector1ShaderProperty).value = (property as Vector1ShaderProperty).value;
}
else if (property is Vector2ShaderProperty)
{
copiedProperty = new Vector2ShaderProperty();
(copiedProperty as Vector2ShaderProperty).value = (property as Vector2ShaderProperty).value;
}
else if (property is Vector3ShaderProperty)
{
copiedProperty = new Vector3ShaderProperty();
(copiedProperty as Vector3ShaderProperty).value = (property as Vector3ShaderProperty).value;
}
else if (property is Vector4ShaderProperty)
{
copiedProperty = new Vector4ShaderProperty();
(copiedProperty as Vector4ShaderProperty).value = (property as Vector4ShaderProperty).value;
}
else if (property is ColorShaderProperty)
{
copiedProperty = new ColorShaderProperty();
(copiedProperty as ColorShaderProperty).value = (property as ColorShaderProperty).value;
}
else if (property is TextureShaderProperty)
{
copiedProperty = new TextureShaderProperty();
(copiedProperty as TextureShaderProperty).value = (property as TextureShaderProperty).value;
}
else if (property is CubemapShaderProperty)
{
copiedProperty = new CubemapShaderProperty();
(copiedProperty as CubemapShaderProperty).value = (property as CubemapShaderProperty).value;
}
else if (property is BooleanShaderProperty)
{
copiedProperty = new BooleanShaderProperty();
(copiedProperty as BooleanShaderProperty).value = (property as BooleanShaderProperty).value;
}
IShaderProperty copiedProperty = property.Copy();
copiedProperty.displayName = propertyName;
graphView.graph.AddShaderProperty(copiedProperty);
}

正在加载...
取消
保存