Skip to content

Scene hierarchy tree view example #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Antoine-Lassauzay
Copy link
Collaborator

Simple example of custom tree view for the scene hierarchy.
It uses UXML draft implementation in conjunction with UQuery.
Also benefits from some adjustments of DataWatch which is now available in all contexts.

added.RegisterWatch(go, UpdateName);
UpdateChildren(added, go.transform);
added.RegisterWatch(go.transform, UpdateChildren);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we need a lambda here because the delegate does not send the VE with it.
We should change all VisualElement delegates to send the 'this' as context.

{
if (data == null)
return;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be multiple labels if we change the template.

void OnToggle(VisualContainer treeViewItem)
{
GameObject go = treeViewItem.data as GameObject;
Debug.Assert(go != null, "No GO attached to item!");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how in the next PR we can have a ViewData service to store and retrieve that.

// Off the cuff?
var v = ViewDataStore.GetOrCreateDefault(key);
var v = ViewDataStore.Store(key, 5);

}
Toggle toggle = treeViewItem.Q<Toggle>();
toggle.enabled = gos.Count > 0;
toggle.on = toggle.enabled && m_ExpandedGOs.Contains(transform.gameObject.GetInstanceID());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toggle state known duplicate code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants