Jump to content
  • Advertisement
Sign in to follow this  
Phobon

[SlimDX][C#] Defining defaults for Vector3

This topic is 2996 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

Hi!

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)
-or-
>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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!