Export

Introduction

The Export delegate allows you to create a custom export for Gum elements. This delegate will automatically be called by Gum whenever an element is saved. By default this occurs whenever the user makes any modification to the element. If your export is especially processor intensive you may consider not adding your export logic here and rather requiring an explicit export by the user.

Code Example

The following code will show a message box whenever an element is exported. Keep in mind this is only for demonstration purposes. By default Gum auto-saves every change made by the user, and showing a message box after every save can be very annoying for users of your plugin.

public override void StartUp()
{
    this.Export += HandleElementExport;
}

void HandleElementExport(Gum.DataTypes.ElementSave element)
{
    System.Windows.Forms.MessageBox.Show("Handling export of " + element);
}

Accessing properties

The above example shows how to react to a component being exported, but it doesn't get at the heart of what an export plugin does.

The first thing that an export plugin needs to do is to access properties on an element (such as its position and size) as well as the instances contained within the element. This information is available through the ElementSave class.

For more information on how to access properties and instances from the ElementSave, see the Gum Class Overview page.

Example Export Code

The following shows what a very simple exporter might look like:

This may produce output that looks like this:

Last updated

Was this helpful?