Color property default values
by Scott Goodwin · in Torque X 2D · 10/01/2008 (10:09 pm) · 1 replies
Is it possible to set a default value for a Color property?
The following doesn't work the way I hoped:
In TXB, this shows up as PackedValue 0.
The following doesn't work the way I hoped:
[TorqueXmlSchemaType(DefaultValue = "Red")]
public Color Whatever
{
get { return _whatever; }
set { _whatever = value; }
}In TXB, this shows up as PackedValue 0.
About the author
Torque Owner Scott Goodwin
//TODO: add all colors defined in Color. public enum Colors : uint { Black = 0xff000000, Blue = 0xff0000ff, DarkBlue = 0xff00008b, DarkGray = 0xffa9a9a9, DarkGreen = 0xff006400, DarkRed = 0xff8b0000, Gray = 0xff808080, Green = 0xff00ff00, Red = 0xffff0000, White = 0xffffffff, Yellow = 0xffffff00, } [TorqueXmlSchemaType(DefaultValue = "Red" )] public Colors Whatever { get { return _whatever; } set { _whatever = value; } } //use to convert from enum to Color public Color AsColor(Colors packedColor) { Color color = new Color(); color.PackedValue = (uint)packedColor; return color; }Is there a better way? Having to define the enum is a pain.