| 1 | # Custom Component in CGE editor |
| 2 | |
| 3 | You can define custom components, specific to your project, that are available inside [CGE editor](https://castle-engine.io/manual_editor.php): |
| 4 | |
| 5 | - Define a new component by creating a class descending from `TComponent`. You will usually want to descend from CGE class like `TCastleUserInterface` (to make new UI components) or `TCastleTransform` (to make new things that can be put inside a viewport). |
| 6 | |
| 7 | The `code/gamecontrols.pas` unit here demonstrates this by defininig `TImageGrid`. |
| 8 | |
| 9 | - Register your component using `RegisterSerializableComponent`. |
| 10 | |
| 11 | - Set `editor_units` in `CastleEngineManifest.xml` to include the unit with your components. |
| 12 | |
| 13 | - Run the custom version of the editor, with your custom components, using _"Project -> Restart Editor (With Custom Components)"_ from the normal editor. |
| 14 | |
| 15 | - Done. Use the new component as a regular component. |
| 16 | |
| 17 | In this example, we placed `TImageGrid` in our main design, `data/gameviewmain.castle-user-interface`. |
| 18 | |
| 19 | See https://castle-engine.io/custom_components for more information how you can extend custom components to look great in CGE editor. |
| 20 | |
| 21 | Using [Castle Game Engine](https://castle-engine.io/). |
| 22 | |
| 23 | ## Building |
| 24 | |
| 25 | Compile by: |
| 26 | |
| 27 | - [CGE editor](https://castle-engine.io/editor). Just use menu items _"Compile"_ or _"Compile And Run"_. |
| 28 | |
| 29 | - Or use [CGE command-line build tool](https://castle-engine.io/build_tool). Run `castle-engine compile` in this directory. |
| 30 | |
| 31 | - Or use [Lazarus](https://www.lazarus-ide.org/). Open in Lazarus `custom_component_standalone.lpi` file and compile / run from Lazarus. Make sure to first register [CGE Lazarus packages](https://castle-engine.io/lazarus). |
| 32 | |
| 33 | - Or use [Delphi](https://www.embarcadero.com/products/Delphi). Open in Delphi `custom_component_standalone.dproj` file and compile / run from Delphi. See [CGE and Delphi](https://castle-engine.io/delphi) documentation for details. |