User avatar
jsantos
Site Admin
Posts: 4123
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noob questions about wether some things are possible or

27 Aug 2013, 13:08

Yes, please, keep up informed with that problem. We are unable to reproduce it here.

And thanks for buying!
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

29 Aug 2013, 19:22

Hi,
I have other remarks, i will continue putting them in this thread in order not to flood the forum.

Stability :

Unity crashes when i modify a script while in play mode.

Features :

Label doesn't behave the same in NoesisGUI and VisualStudio. The Background property doesn't seem to work with label.

The missing dragndrop is a little bit annoying, i have been able to reproduce the dragndrop behavior by making a target panel follow the cursor based on MouseLeftButtonDown and MouseLeftButtonUp but it doesn't work very well as moving the mouse too fast can cause the cursor to exit the bounds of the target panel, then loosing the event of MouseLeftButtonUp.

When i use GridSplitter, NoesisGUI tells me it will ignore this command, is it not supported or did i miss something? I managed to reproduce the behavior i wanted but i have the same problem than with dragndrop, if i move to fast i loose the MouseLeftButtonUp event.

There are some other classes that seem to be unsupported :
TextSearch
RenderOptions
TextOptions
Theses give a parsing error instead of an ignore warning.

How is handeld the small text displaying in NoesisGUI? If there is nothing special done for it i think it wold be nice to have TextOptions.TextFormattingMode="Display" available.

Also, i can't find how to set up a binding procedurally, could you please give me some example code?

At last, i would suggest that you put the script NoesisGUIPanel at a priority execution order when importing the Unity asset, because when you want to access the Noesis.Kernel class and the static methods of NoesisGUISystem in the Awake of another Monobehaviour, without correct script execution order you cannot guarantee that Noesis.NoesisGUISystem will be created before you access to it.
By the way, this makes me think that you cannot have more than one NoesisGUIPanel per scene, is this correct?

Thanks in advance.
 
User avatar
sfernandez
Site Admin
Posts: 3152
Joined: 22 Dec 2011, 19:20

Re: Noob questions about wether some things are possible or

30 Aug 2013, 18:16

Hi,
I have other remarks, i will continue putting them in this thread in order not to flood the forum.

Stability :

Unity crashes when i modify a script while in play mode.
Our plugin doesn't support the modification of scripts during play, but a warning Dialog should appear explaining this situation. If this is not your case, please register at bugs.noesisengine.com and create a ticket attaching the minidump you can generate within our error dialog.

Features :

Label doesn't behave the same in NoesisGUI and VisualStudio. The Background property doesn't seem to work with label.
This all depends on how the Label template is defined. If the template contains an element that binds the templated parent Background property, changes to control Background property will be reflected by the template. Our default Label template is not doing it. But you can create a new template like this:
<ControlTemplate x:Key="LabelTemplate" TargetType="{x:Type Label}">
    <Border Background="{TemplateBinding Background}" UseLayoutRounding="True">
        <ContentPresenter
	    Margin="{TemplateBinding Padding}"
            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
            UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
            RecognizesAccessKey="True"/>
    </Border>
</ControlTemplate>
And apply it to any label:
<Label Template="{StaticResource LabelTemplate}" Content="This is a label" Background="Red"/>
The missing dragndrop is a little bit annoying, i have been able to reproduce the dragndrop behavior by making a target panel follow the cursor based on MouseLeftButtonDown and MouseLeftButtonUp but it doesn't work very well as moving the mouse too fast can cause the cursor to exit the bounds of the target panel, then loosing the event of MouseLeftButtonUp.
To continue receiving mouse move events when mouse goes beyond control bounds you should capture the mouse.
// assuming your script attached to these mouse events
private _dragging = false;
void OnMouseDown(BaseComponent sender, MouseButtonEventArgs args)
{
    UIElement element = sender.As<UIElement>();
    element.CaptureMouse();
    this._dragging = true;
}
void OnMouseUp(BaseComponent sender, MouseButtonEventArgs args)
{
    UIElement element = sender.As<UIElement>();
    element.ReleaseMouseCapture();
    this._dragging = false;
}
void OnMouseMove(BaseComponent sender, MouseEventArgs args)
{
    if (this._dragging)
    {
        // dragging code
    }
}
When i use GridSplitter, NoesisGUI tells me it will ignore this command, is it not supported or did i miss something? I managed to reproduce the behavior i wanted but i have the same problem than with dragndrop, if i move to fast i loose the MouseLeftButtonUp event.
GridSplitter class is not implemented. We will add it to our feature request list if you need it, but we are trying to fix critical bugs before implementing new features.

There are some other classes that seem to be unsupported :
TextSearch
RenderOptions
TextOptions
Theses give a parsing error instead of an ignore warning.
These classes are not implemented. As said before, if you need them we will add them to the feature request list. Anyway, as you noticed, parser should give ignore warnings instead of errors. We will fix it as soon as possible.

How is handeld the small text displaying in NoesisGUI? If there is nothing special done for it i think it wold be nice to have TextOptions.TextFormattingMode="Display" available.
If I correctly understand your question, you are asking about how NoesisGUI deals with small texts. We implemented Subpixel Rendering and Subpixel Positioning for our text render, obtaining great results even on small font sizes. Take a look at this image:
SmallText.png
SmallText.png (6.72 KiB) Viewed 4409 times
Also, i can't find how to set up a binding procedurally, could you please give me some example code?
We missed to expose that API to Unity. We will fix that in a future realease. Sorry for the inconvenience :?

At last, i would suggest that you put the script NoesisGUIPanel at a priority execution order when importing the Unity asset, because when you want to access the Noesis.Kernel class and the static methods of NoesisGUISystem in the Awake of another Monobehaviour, without correct script execution order you cannot guarantee that Noesis.NoesisGUISystem will be created before you access to it.
That is why we advised to use MonoBehavior.Start() to access NoesisGUIPanel data, but maybe this is too restrictive. We will take a look at execution priority as you suggested, thanks for that ;)

By the way, this makes me think that you cannot have more than one NoesisGUIPanel per scene, is this correct?
No, you could add as many NoesisGUI components as you want. Normally you would have one in the Main Camera for the HUD interface, and many others as textures in other game objects.


I hope everything is covered by this long answer :)
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

02 Sep 2013, 06:57

I thanks for this answer, i will use the last version of NoesisGUI a little bit before posting bug reports as i in the patch note that you improved the stability.

I have another question. I am trying to create a custom control by following your tutorial, however i have a parsing error in unity when using the keyword "UserControl". Aren't user controls supported in Unity?

If not could you please advise me on how i could achieve what i want?
I am implementing the inventory in my game, and i would like items to be displayed in an inventory window.
Each items gui will consist in an image, and inside the image there will be the number items the player has in his inventory. There will be a tooltip appearing when hovering the item giving more information.
So i though about creating a UserControl which would contain an image and a textblock to represent the items, and put all theses controls in a stackpanel. But if i can't use UserControl, i'm a little bit lost on how i could achieve that easily.

Also, i have some strange behavior with text.
For example if i start the Button example, when my game window is not maximized, all the text it clear, but when the game window is maximized, "Clicked", the interval value and the delay value become blur.
I also have some panels i created, in one scene the text of theses panels is clear, in another one they are blur... Is there anything to set in order to always have clear text?
(I attached an image showing what i mean)

Thanks in advance.

Edit :
After searching more, i found that the scene difference that made the same panels blurry was the deferred lighting on the camera. However i cannot explain the maximized/not maximized issue.

Edit2:
I did so more test for the maximize/not maximized issue. Actually it's now about maximization, it is about the distance in pixel from the left side of the screen. All the text which is more than 1024px from the left of the screen gets blurred here. I attached an image which shows this issue.
Attachments
1024px.jpg
1024px.jpg (58.42 KiB) Viewed 4389 times
TextCompare.jpg
TextCompare.jpg (125.02 KiB) Viewed 4390 times
 
User avatar
jsantos
Site Admin
Posts: 4123
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noob questions about wether some things are possible or

03 Sep 2013, 16:12

I have another question. I am trying to create a custom control by following your tutorial, however i have a parsing error in unity when using the keyword "UserControl". Aren't user controls supported in Unity?
Yes, UserControl are supported and in fact are being used by the people a lot. I don't know exactly what could be the problem you are having and sergio will help you later for sure. But I think that the problem is that you are using the keyword UserControl directly in the xaml and the rest of our examples are using a class that inherits from UserControl. This could be a bug, although I am not sure if if got any sense directly using UserControl in the xaml.

I did so more test for the maximize/not maximized issue. Actually it's now about maximization, it is about the distance in pixel from the left side of the screen. All the text which is more than 1024px from the left of the screen gets blurred here. I attached an image which shows this issue.
Yes. You nailed it! It is a problem relate to precision. We are using float16 (a version of float with less precision) and it seems that above 1024px the precision is not enough to get a perfect text alignment.

Will be fixed in the next release. Thank you very much for your description and images.
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

04 Sep 2013, 01:30

Hi,
About the UserControl, i am following this documentation :
Docs/Gui.Core.UserControlTutorial.html
In this documentation the XAML contains the keyword UserControl, if i must use another keyword, could you please tell me which one?
Thanks in advance.
 
User avatar
sfernandez
Site Admin
Posts: 3152
Joined: 22 Dec 2011, 19:20

Re: Noob questions about wether some things are possible or

04 Sep 2013, 01:53

UserControls can be created for Unity as explained (not very well, sorry) in our documentation (First steps with NoesisGUI in Unity: Docs/Gui.Core.Unity3DTutorial.html).

First you would create your own UserControl class in a script:
using UnityEngine;
using System;
using System.Runtime.InteropServices;
using Noesis;

namespace CustomControls
{
public class NumericUpDown : UserControl
{
    private HandleRef swigCPtr;

    public static DependencyProperty ValueProperty;

    // This function is required (even if empty) to register the class in NoesisGUI
    // automatically, so objects of this type can be created when XAML is parsed
    public static void Register()
    {
        // Register the dependency properties
        ValueProperty = DependencyProperty.Register("Value", typeof(int),
            typeof(NumericUpDown), new PropertyMetadata((int)0));

        // Here you indicate the xaml file where this UserControl defines its
        // contents
        UserControl.SourceProperty.OverrideMetadata(typeof(NumericUpDown),
            new PropertyMetadata("Assets/CustomControls/NumericUpDown.xaml"));
    }

    public int Value
    {
        get { return GetValue<int>(ValueProperty); }
        set { SetValue<int>(ValueProperty, value); }
    }

    public NumericUpDown(IntPtr cPtr, bool cMemoryOwn)
        : base(cPtr, cMemoryOwn)
    {
        swigCPtr = new HandleRef(this, cPtr);
    }

    public NumericUpDown()
        : this(Noesis.Extend.New(typeof(NumericUpDown)), true)
    {
        Noesis.Extend.Register(typeof(NumericUpDown), swigCPtr.Handle, this);
    }

    public override void Dispose()
    {
        lock (this)
        {
            if (swigCPtr.Handle != IntPtr.Zero)
            {
                if (swigCMemOwn)
                {
                    swigCMemOwn = false;
                    if (Noesis.Kernel.IsInitialized())
                    {
                        Noesis.Extend.Delete(typeof(NumericUpDown), swigCPtr.Handle);
                    }
                }
                swigCPtr = new HandleRef(null, IntPtr.Zero);
            }
            GC.SuppressFinalize(this);
            base.Dispose();
        }
    }

    // Initialize the user control here
    public void OnPostInit()
    {
        RepeatButton upButton = FindName<RepeatButton>("UpButton");
        upButton.Click += OnUpButtonClick;
        RepeatButton downButton = FindName<RepeatButton>("DownButton");
        downButton.Click += OnDownButtonClick;
    }

    void OnUpButtonClick(BaseComponent sender, RoutedEventArgs e)
    {
        Value = Value + 1;
    }

    void OnDownButtonClick(BaseComponent sender, RoutedEventArgs e)
    {
        Value = Value - 1;
    }
}
Next, you design its interface. Remember to specify your class in the root of the xaml using the x:Class property.
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="CustomControls.NumericUpDown"
  x:Name="NumericUpDownControl"
  UseLayoutRounding="True">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <Border Grid.RowSpan="2" Grid.ColumnSpan="2" BorderThickness="1"
          BorderBrush="Gray"/>

        <TextBlock Grid.RowSpan="2" VerticalAlignment="Center" Margin="5,3,4,3"
          Text="{Binding Value, ElementName=NumericUpDownControl}"/>

        <RepeatButton Name="UpButton" Grid.Column="1" Grid.Row="0" Padding="4,1"
          Margin="0,2,2,0">
            <Path Data="M1,1L4,4 7,1" Stroke="Black" StrokeThickness="2"
              StrokeStartLineCap="Round" StrokeEndLineCap="Round"
              RenderTransformOrigin="0.5,0.5">
                <Path.RenderTransform>
                    <ScaleTransform ScaleY="-1"/>
                </Path.RenderTransform>
            </Path>
        </RepeatButton>

        <RepeatButton Name="DownButton" Grid.Column="1" Grid.Row="1" Padding="4,1"
          Margin="0,0,2,2">
            <Path Data="M1,1L4,4 7,1" Stroke="Black" StrokeThickness="2"
              StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
        </RepeatButton>

    </Grid>

</UserControl>
And finally, you can use your own UserControl in other XAML files:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:CustomControls">

    <StackPanel Width="100" VerticalAlignment="Center">
        <local:NumericUpDown Margin="5"/>
        <local:NumericUpDown Margin="5"/>
        <local:NumericUpDown Margin="5"/>
    </StackPanel>

</Grid>
;)
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

04 Sep 2013, 02:24

Hi,

I copy pasted both source code you gave me for the cs and xaml file and i am still getting that parsing error.
I named the cs file NumericUpDown.cs and the XAML NumericUpdown.xaml and placed them in the same folder which in my project is Assets/GUI/CustomControls.

By doing that i get the following error :
[DX9] Assets/GUI/CustomControls/NumericUpDown.xaml
Parsing UserControl (@1,0)
Unknown type 'CustomControls.NumericUpDown'
UnityEngine.Debug:LogError(Object)
Noesis.BuildToolKernel:OnLog(Int32, String) (at Assets/Editor/NoesisGUI/NoesisBuildToolKernel.cs:163)
System.Object:wrapper_native_26730780()
Noesis.BuildToolKernel:Build() (at Assets/Editor/NoesisGUI/NoesisBuildToolKernel.cs:114)
NoesisPostProcessor:Build(String, Boolean, Boolean) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:207)
NoesisPostProcessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:170)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])
I am a little bit lost on what i am doing wrong here. Do you have any suggestion for helping me to debug that?
Thanks in advance.
(By the way, your cs code was missing a } at the end)
 
User avatar
sfernandez
Site Admin
Posts: 3152
Joined: 22 Dec 2011, 19:20

Re: Noob questions about wether some things are possible or

04 Sep 2013, 03:24

UserControl class has to specify where to find the corresponding XAML. If you placed both the .cs and .xaml files in Assets/GUI/CustomControls, you should modify the Register function to point to that folder:
    // ...
    public static void Register()
    {
        // Register the dependency properties
        ValueProperty = DependencyProperty.Register("Value", typeof(int),
            typeof(NumericUpDown), new PropertyMetadata((int)0));

        // Here you indicate the xaml file where this UserControl defines its
        // contents
        UserControl.SourceProperty.OverrideMetadata(typeof(NumericUpDown),
            new PropertyMetadata("Assets/GUI/CustomControls/NumericUpDown.xaml"));
    }
    // ...
I think this should solve your problem.
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

04 Sep 2013, 03:52

Hi,
That was it, the parse error is gone.
Now i feel stupid, i thought the code would work out of the box but i should have read it...
Anyway thanks for your support.

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 0 guests