Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX][C#] Defining defaults for Vector3

This topic is 3084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I'm currently writing an engine on SlimDX, relying heavily on reflection for the editor.
Now I'm trying to add a DefaultValueAttribute to my constructors' parameters which unfortunately fails for any SlimDX-defined type (such as Vector3 etc.)

Maybe a little code shows what I'm trying to achieve:

public class AmbientLight : Light
public Vector3 color { get; set; }
// here's the default value I'd like to set
public AmbientLight([DefaultValue(new Vector3(1,0,0))] Vector3 color)
this.color = color;

Now, the compiler tells me that only constant expressions are allowed as attribute-parameters, so new Vector3(something) is not possible in this case.
So is there any other way to get default variables to these structs despite
>writing wrappers around all the VectorX and matrix types that have a constructor for e.g. float[] (which seems like a big hack to me)
>adding a custom constructor for float[] to all these types and compile my own version of SlimDX (which I'd like to avoid for all the troubles with redistributing, new versions etc.)?

Sorry, if this is a dumb question, I'm pretty new to all these Attributes and reflection... :(

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!