Jump to content

Possibility to view real-time world hierarchy during run (debug)


photo

Recommended Posts

I am wondering if there is a possibility to view a real-time updated hierarchy of the world nodes. This is a feature that both Unity and Godot has, which is really useful. When adding nodes dynamically (with code), it is really nice to be able to pause the game and access game state during running.

If this is not possible, what is your recommended workflow to look at game state, node hierarchy etc during run/debug?

Link to comment

You can use the Syncker plugin to show at run-time the objects hierarchy.

  1. Configure your project and add the Syncker plugin
  2. Add the line -extern_plugin "Syncker" to your run profile
  3. At run-time, press ESC to show the default app menu
  4. Select Plugins and enable Show debug window
    image.png.895f692642b32ceecf2f70d0e2527184.png

I'm not sure though if the Syncker plugin is part of the Community edition.

Link to comment

Hi and thank you for the suggestion. According to the documentation the Syncker plugin (https://developer.unigine.com/en/docs/2.12/code/cpp/plugins/syncker/) is not available for the Community version.

Being used to Unity and the workflow there, I miss the possibility to look at a "real-time" updated hierarchy tree with node properties and also a scene view which is updated and can be freely navigated while "game" is running (or paused).

Hopefully there is something similar that I have not found yet in Unigine Community version.

Link to comment

There's no ready tools for this. You can write your own. This sample shows how to build a hierarchy tree:

treebox->setTexture("core/systems/syncker/gui/nodes_icons.png");
Unigine::Map<int, Unigine::NodePtr> item_to_node;
Unigine::Map<Unigine::NodePtr, int> node_to_item;
Vector<NodePtr> nodes;
World::getNodes(nodes);
for (int i = 0; i < nodes.size(); i++)
{
	// add item
	int item = treebox->addItem(nodes[i]->getName(), nodes[i]->getType());
	item_to_node.append(item, nodes[i]);
	node_to_item.append(nodes[i], item);
	if (!strcmp(nodes[i]->getName(), ""))
		treebox->setItemText(item, String::format("[%s_%d]", nodes[i]->getTypeName(), i).get());

	// set color
	vec4 color = vec4(1, 1, 0, 1);
	color *= nodes[i]->isEnabled() ? 1.0f : 0.6f;
	treebox->setItemColor(item, color);
}

// hierarchy
for (auto i = item_to_node.begin(); i != item_to_node.end(); i++)
{
	NodePtr parent = i->data->getParent();
	NodePtr possessor = i->data->getPossessor();

	if (parent && node_to_item.contains(parent))
		treebox->setItemParent(node_to_item[i->data], node_to_item[parent]);
	else if (possessor && node_to_item.contains(possessor))
		treebox->setItemParent(node_to_item[i->data], node_to_item[possessor]);
}

Then you can create a widget to display the hierarchy.

Thanks.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...