View Single Post
Old 07-24-10, 02:41 PM   #1207
skwasjer
The Old Man
 
Join Date: Apr 2007
Location: Netherlands
Posts: 1,547
Downloads: 26
Uploads: 3
Default

Here's an example:

[SHType]
public class MinMax
{
/// <summary>
/// Minimum value.
/// </summary>
public float Min;
/// <summary>
/// Maximum value.
/// </summary>
public float Max;
}

With the attribute [SHType] and 'class' for this type, it means S3D (and the game) will expect the 'Min' and 'Max' field names preceding the actual value (followed by nullchar).

public struct MinMax
{
/// <summary>
/// Minimum value.
/// </summary>
public float Min;
/// <summary>
/// Maximum value.
/// </summary>
public float Max;
}

Make it a struct, and remove the attribute, then the field names are not 'expected' and the size of the field is explicit by field type (float in this case). This struct is a mere total of 8 bytes, much less then the first 'class' (at 24 bytes).
skwasjer is offline   Reply With Quote