- TheUndeadFish
- Posts: 4
- Joined:
Text not rendering in Unity
A couple weeks ago I setup Noesisgui in a Unity project and got it working fine. This week I've tried setting it up in a different Unity project, and while it somewhat works, no TextBlock element will render at all. This may in fact affect all elements that have text, since a ListBox didn't seem to work either. It's not that the text alone is missing or that the font color matches the background, but the element itself doesn't even show up. However I can put a background color on a StackPanel or Dockpanel, for example, and that will show up fine (so I can tell that rendering isn't entirely broken).
The problem shows up even with the simplest xaml - putting a TextBlock in a top level Grid. But everything appears fine in Blend.
Turning up the log verbosity in the settings doesn't yield anything helpful. There are no errors to point me in any direction. I've tried poking around between the project that works fine and one with problems, but so far I can't figure out what's different.
Unity version 2019.1.6.f1
Noesisgui version 2.2.3
I've probably done something wrong in setting this up, but I can't figure it out. Any ideas?
The problem shows up even with the simplest xaml - putting a TextBlock in a top level Grid. But everything appears fine in Blend.
Turning up the log verbosity in the settings doesn't yield anything helpful. There are no errors to point me in any direction. I've tried poking around between the project that works fine and one with problems, but so far I can't figure out what's different.
Unity version 2019.1.6.f1
Noesisgui version 2.2.3
I've probably done something wrong in setting this up, but I can't figure it out. Any ideas?
Re: Text not rendering in Unity
What platform is this? Do the samples provided in the package work?
- TheUndeadFish
- Posts: 4
- Joined:
Re: Text not rendering in Unity
I'm running this on Windows 7.
The samples seem to work. Specifically looking at a couple render actual text, such as Hello World and Login, the text elements are rendered fine.
The samples seem to work. Specifically looking at a couple render actual text, such as Hello World and Login, the text elements are rendered fine.
- TheUndeadFish
- Posts: 4
- Joined:
Re: Text not rendering in Unity
In my problematic project, I copied the Hello World sample and then simplified it down to:
That displays the text OK at the very top center of the screen.
But I found that if I reduce the grid's top margin (say from 40 to 30), then the text moves up and starts its rendering from above the top of the screen. Similarly if I remove the HorizontalAlignment, then the text starts rendering from outside the left edge of the screen.
Going back to my original xaml that I tried to put together, I had to give one TextBlock a margin of 80,0,0,0 to be where I expect it and another a margin of 80,40,0,0.
So something's up with the coordinate system in this problematic project. Things aren't rendering like the Blend preview (Blend shows as if I don't need these margin adjustments). And the project I have that's working correctly isn't using any margin tricks like this.
Code: Select all
<UserControl x:Class="HelloWorld.MainWindow2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
xmlns:local="clr-namespace:HelloWorld">
<Grid Margin="0,40,0,0" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Hello," FontSize="20" Foreground="White"/>
<TextBlock Text="World!" FontSize="20" Foreground="White" Margin="5,0,0,0" />
</StackPanel>
</Grid>
</UserControl>
But I found that if I reduce the grid's top margin (say from 40 to 30), then the text moves up and starts its rendering from above the top of the screen. Similarly if I remove the HorizontalAlignment, then the text starts rendering from outside the left edge of the screen.
Going back to my original xaml that I tried to put together, I had to give one TextBlock a margin of 80,0,0,0 to be where I expect it and another a margin of 80,40,0,0.
So something's up with the coordinate system in this problematic project. Things aren't rendering like the Blend preview (Blend shows as if I don't need these margin adjustments). And the project I have that's working correctly isn't using any margin tricks like this.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Text not rendering in Unity
What settings do you have in Unity's Game tab for Resolution and Scale (top-left of the Game view). Maybe you have it configured so the render surface is bigger than the actual size of that view so it gets clipped.
Please try it with "Free Aspect" and "Scale 1x" and let us know if that fixes your problems.
Please try it with "Free Aspect" and "Scale 1x" and let us know if that fixes your problems.
- TheUndeadFish
- Posts: 4
- Joined:
Re: Text not rendering in Unity
Well, dang. Turns out that was it. What Unity dev thought it was a smart idea to default that scale to 1.09? This was actually affecting two projects: an old one (that I wanted to resurrect and add Noeisgui to) and one I created new just recently to figure out this issue.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Text not rendering in Unity
Thanks for the update, marking post as solved.
Who is online
Users browsing this forum: Google [Bot] and 25 guests