Components to reuse a design in other designs

1. Introduction

Components TCastleDesign and TCastleTransformDesign allow you to instantiate (reuse) in one design file a component designed in another design file. This is similar to how Unity prefabs are used.

TCastleTransformDesign to instantiate a composition with car+lights multiple times (car model by Slava Z. from <a href="" class="bare"></a> ) TCastleUserInterface to instantiate a composition with button+image+label multiple times (custom images by Ironthunder from <a href="" class="bare"></a> ) TCastleUserInterface to instantiate a composition with viewport+other designs multiple times

2. Video

If you like to learn by watching, we have a nice video about using these components:

3. Overview

The general idea is simple:

Any design file (.castle-user-interface or .castle-transform) can be loaded (instantiated) by TCastleDesign and TCastleTransformDesign). To create such design file, with any component as a root, you can use:

  • Menu item "Design → New Xxx (Custom Root) → Xxx"

  • Or save any component to file using "Save Selected…​" command (right-click on the component in hierarchy).

Then you can reuse it:

  • by manually adding TCastleDesign or TCastleTransformDesign to new designs. Set their URL property to the design that contains the component to be reused.

  • Or just drag-and-drop a .castle-user-interface or .castle-transform file on your design.

See the context menu (right-click) of the TCastleDesign or TCastleTransformDesign for some helpful commands:

  • "Edit (Copy Here) Referenced Design" (detach from the referenced design file)

  • "Revert To Referenced Design" (use after "Edit (Copy Here) Referenced Design"; this removes all the children and reverts back to the original design file)

  • "Open Referenced Design" (an easy way to open design in the URL of this TCastleDesign or TCastleTransformDesign component).

To improve this documentation just edit this page and create a pull request to cge-www repository.