浏览代码

Rename LegacyAttribute to FormerNameAttribute

/main
Peter Bay Bastian 7 年前
当前提交
0055dc00
共有 10 个文件被更改,包括 28 次插入27 次删除
  1. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Channel/SwizzleNode.cs
  2. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalVectorNode.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs
  4. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs
  5. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SampleCubemapNode.cs
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SampleTexture2DNode.cs
  7. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs
  8. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/FormerNameAttribute.cs
  9. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/LegacyAttribute.cs
  10. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/FormerNameAttribute.cs.meta

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Channel/SwizzleNode.cs


void ValidateChannelCount()
{
var channelCount = (int)SlotValueHelper.GetChannelCount(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType);
var channelCount = SlotValueHelper.GetChannelCount(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType);
if ((int)redChannel >= channelCount)
redChannel = TextureChannel.Red;
if ((int)greenChannel >= channelCount)

sb.AppendLine("float Unity_Swizzle_Select_{0}({0} Value, int Swizzle, int Channel)", valueType.ToString(precision));
using (sb.BlockScope())
{
if (valueType == ConcreteSlotValueType.Vector1)
var channelCount = SlotValueHelper.GetChannelCount(valueType);
if (channelCount == 1)
{
sb.AppendLine("return Value;");
}

sb.AppendLine("if (index == 0) return Value.r;");
if (valueType == ConcreteSlotValueType.Vector2 || valueType == ConcreteSlotValueType.Vector3 || valueType == ConcreteSlotValueType.Vector4)
if (channelCount >= 2)
if (valueType == ConcreteSlotValueType.Vector3 || valueType == ConcreteSlotValueType.Vector4)
if (channelCount >= 3)
if (valueType == ConcreteSlotValueType.Vector4)
if (channelCount == 4)
sb.AppendLine("if (index == 3) return Value.a;");
sb.AppendLine("return 0;");
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalVectorNode.cs


namespace UnityEditor.ShaderGraph
{
[Legacy("UnityEngine.MaterialGraph.NormalNode")]
[FormerName("UnityEngine.MaterialGraph.NormalNode")]
[Title("Input", "Geometry", "Normal Vector")]
public class NormalVectorNode : GeometryNode, IMayRequireNormal
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs


namespace UnityEditor.ShaderGraph
{
[Legacy("UnityEngine.MaterialGraph.WorldPosNode")]
[FormerName("UnityEngine.MaterialGraph.WorldPosNode")]
[Title("Input", "Geometry", "Position")]
public class PositionNode : GeometryNode, IMayRequirePosition
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs


namespace UnityEditor.ShaderGraph
{
[Legacy("UnityEngine.MaterialGraph.ViewDirectionNode")]
[FormerName("UnityEngine.MaterialGraph.ViewDirectionNode")]
[Title("Input", "Geometry", "View Direction")]
public class ViewDirectionNode : GeometryNode, IMayRequireViewDirection
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SampleCubemapNode.cs


namespace UnityEditor.ShaderGraph
{
[Legacy("UnityEditor.ShaderGraph.CubemapNode")]
[FormerName("UnityEditor.ShaderGraph.CubemapNode")]
[Title("Input", "Texture", "Sample Cubemap")]
public class SampleCubemapNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireViewDirection, IMayRequireNormal
{

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Texture/SampleTexture2DNode.cs


Normal
};
[Legacy("UnityEditor.ShaderGraph.Texture2DNode")]
[FormerName("UnityEditor.ShaderGraph.Texture2DNode")]
[Title("Input", "Texture", "Sample Texture 2D")]
public class SampleTexture2DNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
{

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs


{
if (type.IsAbstract)
continue;
foreach (var attribute in type.GetCustomAttributes(typeof(LegacyAttribute), false))
foreach (var attribute in type.GetCustomAttributes(typeof(FormerNameAttribute), false))
var legacyAttribute = (LegacyAttribute)attribute;
var legacyAttribute = (FormerNameAttribute)attribute;
var serializationInfo = new SerializationHelper.TypeSerializationInfo { fullName = legacyAttribute.fullName };
s_LegacyTypeRemapping[serializationInfo] = SerializationHelper.GetTypeSerializableAsString(type);
}

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/FormerNameAttribute.cs


using System;
namespace UnityEditor.ShaderGraph
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class FormerNameAttribute : Attribute
{
public string fullName { get; private set; }
public FormerNameAttribute(string fullName)
{
this.fullName = fullName;
}
}
}

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/LegacyAttribute.cs


using System;
namespace UnityEditor.ShaderGraph
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class LegacyAttribute : Attribute
{
public string fullName { get; private set; }
public LegacyAttribute(string fullName)
{
this.fullName = fullName;
}
}
}

/MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/LegacyAttribute.cs.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/FormerNameAttribute.cs.meta

正在加载...
取消
保存