how to change width of box when input sprites? TextMeshPro.preferedWidth doesn't work well with sprite assets, is there any solution for that?
hey guys, I'm try to make a chat box with the sprite asset in TMPro, to show something like that the text in the box is "Hey,guys!< sprite = "emoji" index=1>"
I have some code to control the chat box's width
float height = Text.preferredHeight + 56;
float width = Text.preferredWidth + 37.4f + 37.4f;
box_transform.sizeDelta = new Vector2(width, height);
the problem is when I change the scale of the emoji, what I actually need to do, the preferedHeight didn't change, cause a terrible result like this Is there any way to get a right preferedWidth when i change the scale of the emoji? any help would be greatly appreciated!
Answer by Henry_Xie · Dec 20, 2020 at 10:24 AM
I finnal calculate the width manually to fix this problem, but i still think there should be a better and smarter way to solve it.
Your answer
Follow this Question
Related Questions
How do i reset to the defualt Camera setting(Unity3d) 1 Answer
Plane character selector unity problem 0 Answers
Can't activate unity: License Error 0 Answers
how to connect WEBRTC in unity ? 2 Answers
Unity Image Upscalar 0 Answers