Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何设置float2类型的HLSL参数?_C#_C# 4.0_Xna_Hlsl - Fatal编程技术网

C# 如何设置float2类型的HLSL参数?

C# 如何设置float2类型的HLSL参数?,c#,c#-4.0,xna,hlsl,C#,C# 4.0,Xna,Hlsl,我想知道如何使用C在HLSL着色器效果e中设置p类型float2的参数 似乎不起作用。当使用公开结构类型的属性时,如果一个要更新某些部分而不更新另一部分,通常需要使用以下模式: e.Parameters["p"].SetValue(new Vector2(1, 2)); var temp = thing.SomeProperty; temp.X = 1; thing.SomeProperty = temp; 在您的特定情况下,看起来您想要重写所讨论的结构的所有组件;如果是这样的话,您可以简单

我想知道如何使用C在HLSL着色器效果
e
中设置
p
类型
float2
的参数


似乎不起作用。

当使用公开结构类型的属性时,如果一个要更新某些部分而不更新另一部分,通常需要使用以下模式:

e.Parameters["p"].SetValue(new Vector2(1, 2));
var temp = thing.SomeProperty;
temp.X = 1;
thing.SomeProperty = temp;
在您的特定情况下,看起来您想要重写所讨论的结构的所有组件;如果是这样的话,您可以简单地构造一个新的struct实例并存储它;没有理由先把旧的念出来。虽然有些人可能更喜欢这种格式

var temp = thing.SomeProperty;
temp.X = new Vector2(1, temp.Y);
thing.SomeProperty = temp;

我不太喜欢它,因为它使区分哪些字段正在修改或没有被修改变得更加困难,特别是如果存在不需要指定所有字段值的构造函数重载。

当使用公开结构类型的属性时,如果一个要更新某些部分而不更新另一部分,通常需要使用以下模式:

var temp = thing.SomeProperty;
temp.X = 1;
thing.SomeProperty = temp;
在您的特定情况下,看起来您想要重写所讨论的结构的所有组件;如果是这样,您可以简单地构造一个新的结构实例并存储它;没有理由先把旧的念出来。虽然有些人可能更喜欢这种格式

var temp = thing.SomeProperty;
temp.X = new Vector2(1, temp.Y);
thing.SomeProperty = temp;
我不太喜欢它,因为它使区分哪些字段被修改或没有被修改变得更加困难,特别是如果存在任何不需要指定所有字段值的构造函数重载