The SetByDerived property can allow base Entities to define that it contains a certain Object type which will be assigned in deriving Entities. Keep in mind that both the base and derived Object type must be the same. In other words, if the base Entity has a Sprite Object, then the Entity that derives from the base must also define the object as a Sprite (see below for example).

SetByDerived makes an object “null”

If you set the SetByDerived property on an object to true, that means that Glue will not create that object in the Screen or Entity that contains this Object. This Screen or Entity must be used as a base Screen or Entity to actually create an object.

For example, consider an Entity called Character which contains a Sprite Object with SetByDerived set to true. The Sprite will not be created if you add an instance of Character to another Screen or Entity. The Character must be used as a base for another Entity (such as an Entity called “Monster”).


The following shows how to create an Entity (Base) which defines a Sprite Object which will get SetByDerived. The Derived then re-defines the Sprite.

Creating a Base Entity

  • Right-click on the Entities tree item
  • Select “Add Entity”
  • Name the Entity “Base”


Creating a Derived Entity

  • Right-click on the Entities tree item
  • Select “Add Entity”
  • Name the Entity “Derived”
  • Set the “BaseEntity” property on the Derived Entity to “Entities\Base”


Base and Derived are bad names!
This example uses the names “Base” and “Derived” to clearly indicate the relationship between two Entities. In an actual game, using the names “Base” and “Derived” is a very bad idea! You should always name your Entities in a way to indicate what they are in the context of your game (such as Character or Enemy or PlayerShip). However, if you intend to use an Entity as a base type, it is a good idea to append “Base” at the end of the name (such as “EnemyBase”).

Creating a Sprite object in Base

  • Right-click on the Objects tree item under the Base Entity
  • Select Add Object
  • Select Sprite as the type
  • Name the Sprite SpriteObject
  • Select the newly-created SpriteObject
  • Select the Properties tab
  • Set the SpriteObject’s SetByDerived to True

You should now notice that the SpriteObject appears in both the Base and Derived Object listSpriteObjectBaseAndDerived.png

Be sure to set a type for SpriteObject
You must set a type for the SpriteObject in your base Entity. Otherwise Glue won’t know what types to generate a member for when writing custom code. Make sure that the type in the base and derived match up too.

Defining the Sprite object in Derived

At this point the Derived object already has a Sprite object, but we can define it with more detail. Keep in mind that we must keep the type the same. In other words, we should not change the type from Sprite to something else.

To define the Sprite:

  • Right-click on the Files item under Derived
  • Select “Add File”->”New File”
  • Select “Scene (.scnx)” as the file type
  • Enter the name “SceneFile” as the name
  • Double-click the newly-created Scene file to open it in the SpriteEditor
  • Add a Sprite to the Scene file (for information on using the SpriteEditor, see the SpriteEditor wiki)
  • Save the Scene
  • Select the “SpriteObject” Object in the Derived Entity
  • Change the “SourceType” to “File”
  • Change the “SourceFile” to “Content/Entities/Derived/SceneFile.scnx”
  • Change the “SourceName” to the name of the Sprite that you added in the SpriteEditor


Defining additional Entities

This particular article only covers how to create a Base and Derived Entity. In a larger project you may have one Base Entity and many Entities which derive from Base. Each derived Entity is free to define the Sprite however it wants – each can use a different .scnx file and each can tunnel into this Sprite and set variables in a different way.