Skip to content
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

Game Object/UI/Buttons - RTL Always Create the button in the child of Canvas. #121

Open
AnkitTorenzo opened this issue Jan 25, 2024 · 0 comments

Comments

@AnkitTorenzo
Copy link

This is not as big of an issue compare to others that've seen for this project.

The Problem

Let's say you have a screen and you want to add an RTL-TMP Button. You select a Game Object to be it's parent and from the Game Object>UI you select Button-TRLTMP. I except that the button will be created as a child of the selected Game object, and what I see is that the button is created as a direct child of the canvas. It get annoying very fast especially for a lazy person like me.

Diagnostics

The problem I found is in the ContextMenu.GetOrCreateCanvasGameObject(). As the name suggest It does gives you back a Game Object With Canvas component in it. But this same function is also been used for finding a parent for the Button RTLTMP. And there lies the issue. Since this method return a Game Object with Canvas component, this is what the code assigns as a parent for the button.

Than there is another question this method is also been used in ContextMenu.PlaceUIElementRoot(). But here we are already checking is the selected Game Object has a Canvas somewhere in it's parent or not. And what we want here is a Canvas in-fact any canvas would work because the user did not selected any of the children of a canvas.

Conclusion

This "Button are not being placed as a child of my selected object" really annoyed me, because I am lazy and did not wated drag the button all the way to my desired GO's child. So I fixed it.

I couple of days I will create a PR after clearing out all the Debug.Log()s and some other small things as well. One more thing that I would like to point out that Current behaviour of creating an object is not completely align with Unity's way of doing this. I am also considering fixing that as well. But I will raise a separate PR for that.

AnkitTorenzo pushed a commit to AnkitTorenzo/RTLTMPro that referenced this issue Jan 25, 2024
hojat-shafiee added a commit to hojat-shafiee/RTLTextMeshPro that referenced this issue Apr 7, 2024
Issue pnarimani#121 'Button is not child of selected GO' is resolved
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

No branches or pull requests

1 participant