Gorilla.Prefab Unit Reference
Overview
The Gorilla.Prefab unit provides the prefab system for Gorilla3D. Prefabs act as reusable templates — you store component hierarchies as DFM data and instantiate them at runtime. The system consists of TGorillaPrefab (a single prefab entry) and TGorillaPrefabSystem (the manager component).
Class Hierarchy
TCollectionItem
└── TGorillaPrefab
TComponent
└── TGorillaPrefabSystem
TGorillaPrefab
A single prefab entry in the prefab collection. Stores DFM data and can load/save component hierarchies.
Published Properties
| Property |
Type |
Description |
DisplayName |
String |
Prefab display name |
FileName |
String |
File path to prefab file. Setting does not auto-load |
OwnerComponent |
TComponent |
Root node of the prefab component tree |
DFM |
TStrings |
Inline DFM content. If set, loading skips file access |
Stored |
Boolean |
Whether loaded components are stored in owner DFM |
WriteFormMethods |
Boolean |
Write event properties linked to form methods |
IgnoreUnresolvedEvents |
Boolean |
Silently ignore missing event methods (default shows dialog) |
Published Events
| Event |
Type |
Description |
OnLoaded |
TOnPrefabLoadedEvent |
Fired after prefab components are loaded |
OnStored |
TNotifyEvent |
Fired after prefab is saved |
Public Properties
| Property |
Type |
Description |
OnCreateComponent |
TOnCreateComponentEvent |
Custom component creation callback |
Public Methods
| Method |
Returns |
Description |
Load() |
TList<TComponent> |
Load prefab from DFM or file |
LoadFromFile(AFileName) |
TList<TComponent> |
Load prefab from a specific file |
LoadFromStream(AStream, AIsPrefabZ) |
TList<TComponent> |
Load from stream (supports compressed .prefabz) |
Save(AUpdateFilename, AUseForm) |
— |
Save prefab to current file |
SaveToFile(AFileName, AUpdateFilename, AUseForm) |
— |
Save prefab to a specific file |
SaveToStream(AStream, AUseForm) |
— |
Save prefab to stream |
Callback Types
TOnCreateComponentEvent = function(AComponentClass: TComponentClass;
AParent: TComponent; ALeft, ATop, AWidth, AHeight: Integer): TComponent of object;
TOnPrefabLoadedEvent = procedure(ASender: TObject;
AComponents: TList<TComponent>) of object;
TGorillaPrefabSystem
The manager component that holds a collection of prefabs. Drop onto a form or data module.
Published Properties
| Property |
Type |
Description |
Prefabs |
TGorillaPrefabCollection |
Collection of TGorillaPrefab items |
Public Methods
| Method |
Description |
AddPrefab(AName, AOwner, AFileName) |
Add a new prefab entry |
RemovePrefab(AName) |
Remove prefab by name |
IndexOfPrefab(AName) |
Find prefab index by name |
FindPrefab(AName) |
Find prefab by name (returns TGorillaPrefab or nil) |
LoadAllPrefabs(AList) |
Load all prefabs into a component list |
SaveAllPrefabs() |
Save all prefabs to their files |
See Also