Debian Codegraph @

tools/castle-editor/data/templates/newunitbehavior.pas

raw
1 unit ${UNIT_NAME};
2
3 interface
4
5 uses CastleTransform;
6
7 type
8 ${CLASS_NAME} = class(TCastleBehavior)
9 public
10 procedure ParentAfterAttach; override;
11 procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
12 end;
13
14 implementation
15
16 uses CastleComponentSerialize;
17
18 procedure ${CLASS_NAME}.ParentAfterAttach;
19 begin
20 inherited;
21 { Parent is available now. }
22 end;
23
24 procedure ${CLASS_NAME}.Update(const SecondsPassed: Single; var RemoveMe: TRemoveType);
25 begin
26 inherited;
27 { Executed every frame, can be used to act on Parent, e.g. move it. }
28 end;
29
30 initialization
31 { Optional: If you want to make this behavior available in the editor,
32 add ${UNIT_NAME} to the editor_units="..." in CastleEngineManifest.xml
33 and reopen the project.
34 It will build a custom editor with this behavior available at design-time.
35 See https://castle-engine.io/custom_components .
36
37 Note that you don't *need* to do this.
38 Even without any change to CastleEngineManifest.xml,
39 you can use the new behavior class in code,
40 e.g. create it in the view TMyView.Start method:
41
42 My${BASE_NAME} := ${CLASS_NAME}.Create(FreeAtStop);
43 MyTransform.AddBehavior(My${BASE_NAME});
44 }
45 RegisterSerializableComponent(${CLASS_NAME}, '${BASE_NAME}');
46 end.