浏览代码

Rename PropertyType.Texture to Texture2D

/main
Peter Bay Bastian 7 年前
当前提交
a958b031
共有 8 个文件被更改,包括 15 次插入15 次删除
  1. 2
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs
  2. 12
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/PreviewProperty.cs
  3. 2
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/Texture2DArrayShaderProperty.cs
  4. 2
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/Texture2DInputMaterialSlot.cs
  5. 4
      ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/TextureShaderProperty.cs
  6. 2
      ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/Texture2DAssetNode.cs
  7. 2
      ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/PropertyType.cs
  8. 4
      ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Utility/SubGraphNode.cs

2
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs


switch (slotValue)
{
case ConcreteSlotValueType.Texture2D:
return PropertyType.Texture;
return PropertyType.Texture2D;
case ConcreteSlotValueType.Texture2DArray:
return PropertyType.Texture2DArray;
case ConcreteSlotValueType.Texture3D:

12
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/PreviewProperty.cs


{
get
{
if (propType != PropertyType.Texture && propType != PropertyType.Texture2DArray && propType != PropertyType.Texture3D)
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Texture, propType));
if (propType != PropertyType.Texture2D && propType != PropertyType.Texture2DArray && propType != PropertyType.Texture3D)
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Texture2D, propType));
if (propType != PropertyType.Texture && propType != PropertyType.Texture2DArray && propType != PropertyType.Texture3D)
throw new ArgumentException(string.Format(k_SetErrorMessage, PropertyType.Texture, propType));
if (propType != PropertyType.Texture2D && propType != PropertyType.Texture2DArray && propType != PropertyType.Texture3D)
throw new ArgumentException(string.Format(k_SetErrorMessage, PropertyType.Texture2D, propType));
m_Data.textureValue = value;
}
}

}
set
{
if (propType != PropertyType.Vector2 && propType != PropertyType.Vector3 && propType != PropertyType.Vector4
if (propType != PropertyType.Vector2 && propType != PropertyType.Vector3 && propType != PropertyType.Vector4
&& propType != PropertyType.Matrix2 && propType != PropertyType.Matrix3 && propType != PropertyType.Matrix4)
throw new ArgumentException(string.Format(k_SetErrorMessage, PropertyType.Vector4, propType));
m_Data.vector4Value = value;

public void SetMaterialPropertyBlockValue(MaterialPropertyBlock block)
{
if ((propType == PropertyType.Texture || propType == PropertyType.Texture2DArray || propType == PropertyType.Texture3D) && textureValue != null)
if ((propType == PropertyType.Texture2D || propType == PropertyType.Texture2DArray || propType == PropertyType.Texture3D) && textureValue != null)
block.SetTexture(name, m_Data.textureValue);
else if (propType == PropertyType.Cubemap && cubemapValue != null)
block.SetTexture(name, m_Data.cubemapValue);

2
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/Texture2DArrayShaderProperty.cs


public override PreviewProperty GetPreviewMaterialProperty()
{
return new PreviewProperty(PropertyType.Texture)
return new PreviewProperty(PropertyType.Texture2D)
{
name = referenceName,
textureValue = value.textureArray

2
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/Texture2DInputMaterialSlot.cs


public override void GetPreviewProperties(List<PreviewProperty> properties, string name)
{
var pp = new PreviewProperty(PropertyType.Texture)
var pp = new PreviewProperty(PropertyType.Texture2D)
{
name = name,
textureValue = texture,

4
ShaderGraph/com.unity.shadergraph/Editor/Data/Graphs/TextureShaderProperty.cs


public override PropertyType propertyType
{
get { return PropertyType.Texture; }
get { return PropertyType.Texture2D; }
}
public bool modifiable

public override PreviewProperty GetPreviewMaterialProperty()
{
return new PreviewProperty(PropertyType.Texture)
return new PreviewProperty(PropertyType.Texture2D)
{
name = referenceName,
textureValue = value.texture

2
ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/Texture2DAssetNode.cs


public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(new PreviewProperty(PropertyType.Texture)
properties.Add(new PreviewProperty(PropertyType.Texture2D)
{
name = GetVariableNameForSlot(OutputSlotId),
textureValue = texture

2
ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/PropertyType.cs


public enum PropertyType
{
Color,
Texture,
Texture2D,
Texture2DArray,
Texture3D,
Cubemap,

4
ShaderGraph/com.unity.shadergraph/Editor/Data/Nodes/Utility/SubGraphNode.cs


case PropertyType.Color:
slotType = SlotValueType.Vector4;
break;
case PropertyType.Texture:
case PropertyType.Texture2D:
slotType = SlotValueType.Texture2D;
break;
case PropertyType.Texture2DArray:

var id = prop.guid.GetHashCode();
MaterialSlot slot = MaterialSlot.CreateMaterialSlot(slotType, id, prop.displayName, prop.referenceName, SlotType.Input, prop.defaultValue, ShaderStageCapability.Fragment);
// copy default for texture for niceness
if (slotType == SlotValueType.Texture2D && propType == PropertyType.Texture)
if (slotType == SlotValueType.Texture2D && propType == PropertyType.Texture2D)
{
var tSlot = slot as Texture2DInputMaterialSlot;
var tProp = prop as TextureShaderProperty;

正在加载...
取消
保存