Debug the hierarchy


I would like to know if it is possible to see how the objects’ hierarchy changes in real time in the editor when you create/add/remove objects from scripts.

This is something that it is possible in Unity, but I do not see how to see my changes reflected in the PlayCanvas editor when these changes are performed through scripts (they are reflected if the changes are done from the editor).

It is really important for us, since it would allow us to speed the debug process. Right now it is hard to actually get a clear picture of the state of the hierarchy if you perform several actions to the scene tree from the scripts.

Thanks in advance.

How would you like to see that?
Like, get notifications of changes in hierarchy? Or log it somewhere? Or just see actual tree of entities?..

Anyway, you can write it easily by recursion.

Unfortunately not.

I’ve debugged this in the past via printing out the scene hierarchy in console log via a key press. I’ve been tempted to print it out to the scene so it could be seen in real time. It’s expensive though. Another solution is to only update the debug output when add/remove is called via Monkey Patching.

Why? You can hash your current state and compare it with new hash every frame. If it was changed - redraw it async.

Yes, I would like to see the changes I made reflected in the editor hierarchy (the actual tree of entities).
It would be very very useful. Much more useful than writing it to a console.

In fact I think it’s the most important feature missing in the editor…

I guess the answer is that it’s not possible at the moment.

What’s monkey patching?
I don’t understand what you propose but if it is a solution for seeing the actual tree in the editor I am interested.

You want to make changes in hierarchy in game and see changes in Editor?

That’s something that is possible Unity since the first versions.

Editor is for editing, you mean profiler.


We have one, but it has no function to show your hierarchy. So I said before, you can white it by yourself. Some people would really appreciate it.

I mean editor, not profiler.
In Unity the hierarchy is shown in the editor and changes in real time while playing.

Besides, if you add objects in PlayCanvas (using the editor) while playing/debugging, the object is shown in the hierarchy.

I really don’t understand why it does not happen the same when you create an object within the code.

In Unity you play your game in editor. So your profiler is right there.
Playcanvas has separated editor and game, and I think it’s better.
And, as you can see, we have independent profilter. Since that, you can extend it by your own.

That does not explain why if you add objects in PlayCanvas (using the editor) while playing/debugging, the object is shown in the hierarchy, but not if you do it with code.

Why is that?


Because Editor and game are separated.

Editor can update components of your entities right in game, if you changed it in Editor, but there is no back connection.

This would be ridiculous, if you occasionally remove your whole geometry in game and it disappear from your project.

This problem is solved in Unity.

If you perform changes (via script) while playing, they are shown in the editor, but when you stop the player, the editor returns to the original hierarchy.

Therefore, I think it is perfectly possible…
… and strongly desirable IMO.

No, Unity created this problem. You used to use this instruments and workflow and now you feel uncomfortable with other tools.

PlayCanvas is little bit more low-level that Unity, so you have to be more programmer than designer.

When you play your scene in Unity it keeps your state and you can change it in runtime, but in this moment, your editor is profiler. And its wrong. I dont know how to say in in English, but there is a russian idiom for that - “it makes your hands crooked”.

I agree with @Sergio_Casas that in some situation would be really useful to have the editor to reflect the changes applied by code at runtime. Or, if not the editor, another kind of viewer that allows inspecting what is where, and what attributes the objects have at runtime.

This is very needed when you create script the procedurally generate or place objects, and you need to see where they are. Because most of the time you don’t get it right on the first shot and you simply don’t see them in the game view.
This applies to 3D and 2D too.

For example, I was creating a horizontal layout script to distribute 2D elements side by side at intervals automatically calculated based on element sizes.
I hit play, and I don’t see them. Then the only way to see what is going on is to use breakpoints and “see” the coordinates to understand what is going on.
Would be much easier if I could just use the editor camera to see the scene, select elements and read their properties in the inspector.

There are many more examples I could give (shader coding - that now can’t be seen at all in the editor, inspecting physics behavior, etc…) that would be much simpler by having a scene viewer with hierarchy and values inspector.

Of course, allowing to edit runtime values for testing and debugging would even better, because now you can only edit at runtime values int the editor for objects that are already there from the start and not for objects added by code.

I couldn’t explain it better.
That’s exactly the point.

The fact that is not implemented does not mean it is not necessary. It is…

Yes, but in some points I can’t agree with you.

Hierarchy debug - is a multi-purpose feature, I would need that too.

But this is profiler’s feature, not Editor.

For example, I have only one monitor and changing tabs to control game and it’s state would be uncomfortable, but profiler runs right in game’s tab.

Tbh, Playcanvas profiler is little poor. Compare it with Yii2 profiler, it has a lot of useful features.

Sure, it’s backend-profiler, but still, hierarchy view would be really useful, for sure.

I think you are missing the point. We are not speaking at all of profiling to test speed or memory allocation.
We just need to see the objects with an independent camera, allowing us to select an object (by clicking on it or selecting it from a hierarchy) and see/change all its values with the same visual panel of the editor.

About using only one monitor, nothing prevents the debug mode to have an additional camera and UI to see the hierarchy and the inspector. These elements could be just enabled/disabled by some key combination, so you show them only when you need.

Of course, this could be coded but is a lot of work, and having the editor already implementing all these features, could be much easier to start from it.

Okay, yes, we need a modern debug-panel, with profiler and hierarchy inside, do you agree?

It’s just semantic. You can call it as you like, but it shouldn’t affect to Editor in anyway.