Tag: Vector2

Articles and experiments related to Vector2.

Assigining a TypeConverter to a class you don't own

In this post, I describe a solution to a problem I encountered while working with XNA Beta1 and Vector2 structs. Because Vector2 didn't have an associated TypeConverter, the designer lacked support. Applying a TypeConverter to the property worked in the designer, but Visual Studio 2005 ignored it during serialization, resorting to resource files, which was messy. My workaround involves dynamically adding a TypeConverter to the Vector2 type itself using TypeDescriptor.AddAttributes, which is invoked during the class's construction. By registering the Vector2Converter with the Vector2 type early on, both the designer and code serialization work harmoniously.

Read article

XNA Vector2 Type Converter

I was developing a component in XNA and needed a way to edit Vector2 properties directly within the Game Designer. Since Vector2 is a struct and doesn't inherently support this, I created a custom TypeConverter. The provided code allows you to modify Vector2 values in the designer using comma notation (e.g., 50, 100). Feel free to adapt it for other types like Vector3.

Read article

Stay in the loop.

I'm trialing a newsletter. Join for monthly insights into web dev, Chrome, and the open web.

alternate_email

Get in touch

Open to chat about Chrome or Web development.

Book a consultation