0

I want to create a chat box. Messages should have a border. Also message could be located in one of two sides, I mean right or left side. I have made two prefabs, one for left-side message and second one for right-side message. When I add some prefab in chat box it works fine, I can see the border. But when I do it by the script, then the border is invisible. Here is the structure. enter image description here

The "Content" has Vertical Layout Group component with checked Width, and Content Size Fitter with Horizontal Fit - Unconstrained and Vertical Fit - Preferred Size.

The "Message left" has Horizontal Layout Group with unchecked Width and Height, and Layout Element with all unchecked.

The "Message (1)" has Content Size Fitter with Horizontal Fit - Unconstrained and Vertical Fit - Preferred Size, Horizontal Layout Group with Width checked, and Layout Element with Preferred Width - 291.5, and Flexible Width - 0.

Also here is two imaged, with border and without border.

enter image description here enter image description here

UPDATE: The border is on "Message (1)" and it looks like enter image description here

So how do I fix it? Is there a solution?

UPDATE2: I have fixed it. The problem was in Z scaling of sprite, I set it to 0, but it has to be 1.

Community
  • 1
  • 1
user2686299
  • 427
  • 8
  • 25
  • And what renderer supposed to draw that borders? I`m not very familiar with unity 5 gui, so I cant say if it is some custom part of your prefab or native gui component. – Synthetic One Jan 18 '16 at 08:19
  • We would need to know where exactly this border sprite is located. Please give this info and check if you after instantiating set the scale to 1 (or whatever is proper for you) – Jerry Switalski Jan 18 '16 at 09:55
  • of course I set the scaling to 1 and position to 0. – user2686299 Jan 18 '16 at 11:41
  • the border is on "Message (1)" and it looks like http://puu.sh/mAaou/ff6356a8eb.png – user2686299 Jan 18 '16 at 11:45
  • in Edit mode it works fine with any picture as border, but in Play mode nothing works, the picture just invisible – user2686299 Jan 18 '16 at 11:46

1 Answers1

0

The problem was in Z scaling of sprite, I set it to 0, but it has to be 1.

user2686299
  • 427
  • 8
  • 25