Custom component. Doesn't show on basic tap

Hello, I making a Custom Component, but the properties doesnt show in basic tap.

I got this:

public
const
DefaultDistancia = 50;
property Direccion: TVector3 read Fdireccion write Setdireccion;
property Velocidad: TVector3 read Fvelocidad write Setvelocidad;
published
property Distancia: single read FDistancia write SetDistancia default
DefaultDistancia;
property DireccionPersistent: TCastleVector3Persistent read FDireccionPersistent;
property VelocidadPersistent: TCastleVector3Persistent read FVelocidadPersistent;

if ArrayContainsString(PropertyName, [‘VelocidadPersistent,DireccionPersistent’]) then
begin
Result := [psBasic];
end
else
begin
Result := inherited PropertySections(PropertyName);
// Result := [psBasic];
end;

If I “force” resutl to psbasic the propierties are show in tap. So the problem is that are not found in the array. But I don’t know why

/BlueIcaro

Hm, I don’t see any obvious error in the code you show. Checking if ArrayContainsString(PropertyName, [... follows the pattern we use throughout CGE , and our properties show in “Basic” tab OK.

You need to show a bigger piece of code (preferably a complete testcase, i.e. code that we can compile and test) to allow us to debug it.

Note: You can also debug more on your side

  • e.g. from Lazarus IDE (CGE editor is a regular LCL application, you can set a breakpoint e.g. the beginning of your PropertySections method).
  • adding WritelnLog. E.g.
WritelnLog('Checking property %s, which seems to be in array? %s', [
  PropertyName,
  BoolToStr(ArrayContainsString(PropertyName, [‘VelocidadPersistent,DireccionPersistent’]), true)
]);

The editor makes a regular log file, you can find it following docs Logging | Manual | Castle Game Engine (the application name of editor is castle-editor). So if you add above WritelnLog inside your PropertySections, make a test, and later look at log → you should see something that helps :slight_smile:

Hello, here is the complete project.

Thanks

/BlueIcaro

Thank you!

Looking at GitHub code listing, with proper syntax highlighting (colored Pascal string), I can see the issue at GhostAndGoblins_CGE-/Capitulo 8/code/enemigos/gamezombiesbehavior.pas at c4489ea1c33b3b6f9561ac1190e50536592b180d · Blueicaro/GhostAndGoblins_CGE- · GitHub (which was also in your post above, I just didn’t see it):

You placed the comma inside a string in the condition:

if ArrayContainsString(PropertyName, [‘VelocidadPersistent,DireccionPersistent’]) then

That is, you’re not comparing PropertyName with 2 possible strings, one VelocidadPersistent, other DireccionPersistent. You are comparing it with 1 string (containing a comma inside, so it will never match a Pascal identifier) VelocidadPersistent,DireccionPersistent.

Simply adding apostrophes should make it valid:

if ArrayContainsString(PropertyName, [‘VelocidadPersistent','DireccionPersistent’]) then

Please note that in the end, I didn’t test above solution – I’m writing this basing on looking at the code. If some problem in this case remains, please let me know.

Hello, Thank you!

/BlueIcaro

P.D. ups! :sweat_smile: Note to self: Sleep more and program less at night

1 Like