Search Unity

NoesisGUI : XAML-based User Interface [RELEASED]

Discussion in 'Assets and Asset Store' started by sfernandez, Jul 23, 2013.

  1. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I found an alternate workaround for that adb.exe problem. I've been playing some more with the trial version, and I noticed that if I go ahead and connect an Android device and fire up adb.exe (I did "adb devices" in a command prompt to get the daemon running), then Unity won't keep trying to automatically fire up another one and I don't have to keep killing the "mess everything up" one.

    I can close and re-open Unity and it'll still behave properly. Things seem to be more stable in general with NoesisGUI when I do that too.
     
  2. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    Thanks for that one :D
    I will add the tip to the related thread in our forums so anyone can benefit from your discovery.
     
  3. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    In general, is it better to discuss NoesisGUI here or on your forums? I tend to post here, since I already have a Unity forum account. :)
     
  4. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    As you wish... normally people that discover the product write here but when they start to use it (and buy a license) they change to our forum. We see unity forum as a way to attract new users and our forums as a professional way to receive feedback and solve user problems.

    Apart from all this, licensees can report bugs privately using our bug tracker.
     
  5. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    Your tool looks great, when will you have support for windows mobile?
     
  6. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I had a question about text rendering crispness when rendering a Noesis UI to a render texture (where it's used on a quad that may be at an angle to the gameplay camera). I've been comparing NGUI, DFGUI, and NeosisGUI in terms of how they handle that. It works surprisingly well in NGUI, especially given the bitmap nature of how that works. I haven't gotten the transparency for that working yet in DFGUI, but I imagine it'll look the same, since it really work the same way.

    In NoesisGUI, it's cool that you can simply change the background to zero alpha in the XAML and it just works. The text seems a bit aliased though, which really surprised me, since the vector approach I figured would make everything super smooth.

    Is there a way to smooth out the jaggies on text any more? I tried switching to a 2048 x 2048 render texture (and double the font size), changing the render texture to 8x anti-aliasing, and the hardware anti-aliasing to 8x, but none of that made a difference. I guess the vector -> bitmap stuff happens before any of that or whatever? I also tried PPAA anti-aliasing in the UI Panel just for grins, but that didn't help either.

    Here's a 2x zoom of a portion of my test to show you what I mean:
    $RenderToTextureScalingZoomX2.PNG

    When I tried a similar thing in NGUI, I get smoother text with only a 1024 x 1024 render texture, and this text is actually smaller (this is also zoomed 2x):
    $NGUI_render_to_texture_ZoomX2.png

    Now in fairness, what's unique about NoesisGUI is that when I moved the camera in really tight, the text never got any *worse* - obviously with a bitmapped approach, that would result in a blurry mess.
    $RenderToTextureCameraPushIn.PNG
     
  7. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    Could you please try comparing NoesisGUI vs NGUI with the same .ttf, the same font size, the same foreground color, the same background, and the same RenderTexture settings (size, filter, aniso)?
     
    Last edited: Aug 28, 2013
  8. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Hi, I was investigating this issue with sergio this morning. We think that with the same font, same background and same resolution the result should be very similar to NGUI. In fact, we think it should be a little bit better.

    Anyway rendering to texture has its limitations (I think that this points affects NGUI and NoesisGUI):

    1. You need automatic generation of mip maps to avoid aliasing. I am not sure if this is implemented right in Unity but I think that it could explain part of the aliasing you are observing (and the fact that when you zooming the text renders correctly). I think that if you use an smaller texture the result should improve.

    2. The bilinear filtering washes out the aspect of the GUI. This is not a big problem but for fine details (like text) it can be very important. If mipmaps are active you need trilinear here.

    3. Thanks to your sample we have discovered a bug (at least one...). When rendering to texture we should disable the subixel filter (https://www.grc.com/cleartype.htm) we are applying because that filter must only be used when rendering to screen. Being rendered to a texture we dont know the final orientation of the text and artifacts appear (like the strange colors that are appearing in the borders, instead of the yellow).

    4. An better alternative with NoesisGUI is using 3D projection to get the same effect. You avoid wasting texture memory and the quality could be a bit better. Problem is that there are scenarios where this cannot be used, or you need explicitly a texture.
     
  9. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    We are working on it. Give us a few months for that and you will have it. :)

    Several clients bought us (to support our work) and are waiting for that platform.
     
  10. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I've been attempting that, but now I can't even get the scene I had to work. I had used the RenderToTexture sample scene and then just replaced TuxClear.xaml with a very simple XAML I wrote that just has text in the four corners.

    But now I'm getting "Exception: [DX9] Resource Assets/NoesisGUI/Samples/RenderToTexture/LionClear.xaml not found" and I see a solid dark gray color on the left cube and a light gray color on the right cube. I didn't change anything with the lion image. If I disable Cube Left, then I get the same error, but for HUD.xaml. Those are definitely still there. I guess I'll try creating a new scene; I'll post shots if I get anywhere with that.
     
  11. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I did start out with a smaller texture, but it looked basically the same. FYI, the images I posted are a little misleading. It's a bit of an optical illusion that the text looks "correct" with the camera pushed in close like that. The amount of aliasing actually looks the same in reality, but it's less apparent because of the relative size of the text.

    I did try setting trilinear filtering with anisotropic level 9 on the render texture, but it didn't have any effect. I don't know if that automatically turns mipmap generation on when you set those things in the editor.

    I did notice some slightly funny colors in there.

    For my specific scenario, I'm looking to have an in-game HUD (as in a pane of glass that the UI is drawn on) that's in a spaceship cockpit. Same idea as a real HUD on an F-16 or whatever. I've got a "freelook" option, so when the player looks around, the HUD should remain at the front of the cockpit. So it just needs to be a square image. Later I may experiment with an additional in-helmet HUD that moves with the player. I may be able to just do a regular UI for that, or I may try to map a render texture onto a curved model that represents the curved glass of a helmet.

    Can you tell me how to use the 3D projection feature? I've seen it mentioned, but I haven't seen anything on how to actually use it (or really even what it is).
     
  12. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I still haven't been able to do an apples-to-apples test with the same font (any time I try to reference a specific font, I get a "not found" error on the XAML file itself). I did create a scene that uses both NGUI and NoesisGUI and overlaid two quads with just a slight Z offset, one with an NGUI label in a corner and the other with a NoesisGUI. Both render textures are 1024 x 1024.

    What's weird is that there seems to be some sort of interaction between the two packages. The NoesisGUI is flipped vertically. So I wasn't even able to line up the same text. But I did get a good image that illustrates the color issue. The second line is from a Noesis UI (it's the words "LOWER LEFT" flipped vertically). I wonder if the color issue is the only real issue here:
    $RenderTexture_AA_colors.PNG
     
  13. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    To use fonts in NoesisGUI you should create a <Font Family Name>.font file describing the .ttf used by the font family. For example, if you plan to use Arial font family in your interface you should create an Arial.font file next to the .ttf files containing the following lines:

    arial.ttf
    ariali.ttf
    arialbd.ttf
    arialbi.ttf

    Then, in your xaml you will use that font resource this way (assuming you place the .font and related .ttf files in a subfolder called Fonts next to the xaml file):

    Code (csharp):
    1.  
    2. <Grid
    3.   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    4.   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    5.     <TextBlock FontFamily="Fonts/#Arial" FontSize="20" Text="Hello World"/>
    6. </Grid>
    7.  
    I'm quite sure that using the same font and after we fix the problem with the coloured edges, the results will match NGUI.

    We will investigate about the vertical inversion thing, it's very strange that we can interact in any way with NGUI.
     
  14. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Yeah, that's exactly what I did originally, but every time with my font (and even with the Roboto font file copied from one of the examples), I would immediately get a "Whatever.XAML not found" error. I just tried uncommenting my font reference again, and for whatever reason, now it works. Weird.

    So anyway, I *can* get it to use my own font now.
     
  15. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Is the XAML building correctly? I mean, the error "Whatever.XAML not found" (that has been changed in the next release to be more explicit) means that the XAML has errors. Don't you get any extra message in the Console?
     
  16. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Just for grins, I removed all references to NGUI from my test project, and the texture when applied to a quad was still flipped vertically. I tried putting the material on a cube, and it was flipped horizontally.

    For now, I actually can get apples-to-apples, since I can set the Y scale of the quad to -1 to flip it around.
     
  17. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    No, as I recall, the console would say one of three things: "Whatever.xaml not found", "Whatever.xaml not in database", or something that started with [DX9] that wasn't specific.
     
  18. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Could you send me the project??
     
  19. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    And... could you send me a project with this problem too? I would like to inspect the problem...

    :)
     
  20. Knertified

    Knertified

    Joined:
    Jul 3, 2012
    Posts:
    31
    Hi,

    I just purchased Noesis after using the Trial. I was able to create a XAML file in Visual Studio and successfully import it into my scene. I absolutely love the product and how clean my code is. However, after purchasing the product I have a major problem. Although everything renders fine in the Unity Editor, when I build for iOS everything goes haywire. Sometimes it complains of missing scripts.. sometimes it just crashes on EXC_BAD_ACCESS and the rest of the time my scene shows but with a corrupted flickering T like below.

    I have tried removing code stripping completely and allowing full .NET 2.0. I've also removed my XAML and added the Button.xaml test file that came with the plugin and the exact same thing occurs. I have also cleaned all my build directories in both Unity and Xcode (Derived Data).

    Help!

    $IMG_0052.PNG
     
  21. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Hi!

    Rapid answer: do you have the platform iOS active in Window->NoesisGUI->Settings?

    If this is not the problem, we are going to need the project and the execution log. Could you please register yourself in our forums?
     
  22. Knertified

    Knertified

    Joined:
    Jul 3, 2012
    Posts:
    31
    Wow that was quick! Yes I have IOS enabled :)

    I just created a vanilla project , imported NoesisGUI and and everything worked okay on iOS so what I am doing is disabling all of my components and re-enabling them one by one to find the culprit. I have a lot of 3rd party plugins from the asset store :)

    I'll go ahead and register on the forums tonight.
     
  23. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Our samples work correctly on iOS (at least on the devices we have here), but yes there could be problems with more complicated scenarios or even with interactions with other 3rdparties (for example, we are now investigating an issue with NGUI).

    I told you about our forums because there we can give you better support. As soon as you register email us please to give you permissions to download new versions directly from our servers.

    Thanks!
     
  24. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    Looking into the project you sent to us I found the problem with the font definitions. Maybe it is not well explained in our documentation, but the name of the .font file must match the name of the font family. In your project you were using the "AgencyR.ttf" file which defines the font family "Agency FB". Notice the white space between the two words. That means you should create a file named:

    Agency FB.font

    And when you use that font in your xaml, you have to use the exact font family name too:

    <TextBlock Text="Hello World" FontFamily="Fonts/#Agency FB"/>
     
  25. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I noticed that if you double-click on the TTF file in Windows, it shows you the actual font family name. Yeah, I figured the .font file name was arbitrary; I didn't realize it needed to match that value.

    What's really bizarre though, is that it started working even without the space. But I'll make sure to name those correctly from now on.
     
  26. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Hi Steve,

    Well, it is not strictly necessary that those name match. But if you want to have the XAML compatible wiht Blend and NoesisGUI that is the only way. That explains why it was working you.

    As I told you in private we have a UV convention that is the opposite to Unity (so it not NGUI making harm haha). For now your solution of flipping is correct.

    So, you can continue with your comparison and tell us.
     
  27. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    And btw, there is a new Trial version!
     
    MarkusHenrich likes this.
  28. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
  29. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Any news on this?

    By the way, when you register at our forums please email me the invoice number of the purchase to allow you download new versions from our web. There is already a new version that will take several days to appear in the store.
     
  30. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    I've installed the trial version and I've run a couple of examples. (Tic Tac Toe and the Dashboard ) but whenever I quit Unity 4.2.1 Unity locks ups. Also when running and example it seems really slow to actually start the scene.
    Also, when I then try to restart Unity it seems to take forever or hang on boot up. This has never happened to me before installing the Noesis package.

    I've rebooted my PC many times but currently the seems seems unusable. Is this just me?


    Windows 8, i7, 32 GB.
     
  31. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    You have probably found this problem

    http://www.noesisengine.com/forums/viewtopic.php?f=3&t=92

    does the workaround described there work for you?
     
  32. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
  33. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    I think NoesisGUI is really cool. I played around with it a little during the beta and am now considering using it for 2 or 3 projects that are very GUI heavy (since UT doesn't deliver, I guess I'll finally have to work with alternatives ;-) ). It is very painful for me that Web Players are not supported but for these projects I can probably live with that.

    Do you somewhere have a "platform sheet"? The information I need: Which of the platforms that Unity supports are supported by NoesisGUI? And which are planned to be supported? And - just roughly - when?

    So ... from http://unity3d.com/unity/multiplatform/

    Desktop:
    • Mac
    • Windows
    • Windows Store (this is for Windows 8 - question here is: does NoesisGUI play well with Windows Store builds?)
    • Linux

    Web:
    • Unity Web Player (I understand the technical limitations - are you talking to UT about integrating your technology into the Web player? This would be the preferred solution for me ... Web players really matter and they're now pretty widely adopted as well)

    Mobile:
    • iOS (I know this works)
    • Android (also seems to be supported)
    • Windows Phone 8 (you mentioned it's on the roadmap ... "in a few months")
    • Blackberry

    Consoles (for completeness):
    • PS3
    • Xbox 360
    • Wii U

    Regarding mobile, I have one more question: How are you handling touch input? Is that directly supported by NoesisGUI or does NoesisGUI require custom implementations? In particular, what about gestures like swipe / pinch etc. ... like, for navigating scroll lists and the like (e.g. is it properly supported that I can swipe to scroll but tap to select?)
     
  34. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Hi jashan,

    Working:
    • Mac 32 bits
    • Windows 32bits DirectX9
    • iOS
    • Android
    Almost finished (alpha stage):
    • Mac 64 bits
    • Windows 64bits
    • Linux
    In the roadmap (beta in 2 months)
    • DirectX11
    • Windows Phone and Windows Store
    WebPlayer (using Unity plugin or chrome NACL) does not support native plugins. No much options here (apart from thousand of users demanding a solution to UT). We will have to wait to Unity supporting HTML5 + WebGL.

    Rest of platforms are not planned for now.

    We are working on this. We have a high priority plan to incorporate Xaml touch keywords to NoesisGUI. For now, custom implementations are required. It is not very complex but of course not as easy as the automatic one.
     
  35. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Linux port reached Alpha stage. I have been playing with this new toy today and everything is working quite well!
     
  36. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    Sorry for missing these questions, but better late than never answer :rolleyes:

    If you plan to render the GUI on a curved model you definitely need to do a render to texture. 3D projection feature will work better for adding some perspective to UI panels, like in Dead Space:

    $0000006495-1024x7681.jpg


    To add a 3D projection to any element you have to use the Projection property. It accepts a PlaneProjection or Matrix3DProjection object to specify the 3D projection in different ways. Here is a simple example:

    Code (csharp):
    1. <Grid
    2.   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3.   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    4.     <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Background="#40AAAAAA">
    5.         <StackPanel.Projection>
    6.             <PlaneProjection RotationY="20"/>
    7.         </StackPanel.Projection>
    8.         <Button Content="Start" FontSize="20" Padding="50,10" Margin="20,10"/>
    9.         <Button Content="Settings" FontSize="20" Padding="50,10" Margin="20,10"/>
    10.         <Button Content="Exit" FontSize="20" Padding="50,10" Margin="20,10"/>
    11.     </StackPanel>
    12. </Grid>
    $proj3D.png
     
    Last edited: Sep 6, 2013
  37. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Thanks for the followup! Yeah, if 3D projection is really just for some subtle rotation like that, that wouldn't work. The HUD's in my game exist in the 3D game world, so render textures I think make the most sense.
     
  38. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    NoesisGUI v1.0.3

    >> Buy from Asset Store

    • New Tutorial: First Steps with Blend in Unity
    • Added StreamGeometry converter to allow things like this: <StreamGeometry>M0,0 L100,0</StreamGeometry>
    • Implemented callbacks for showing software keyboard on touch devices
    • Improved text rendering with transforms. Now text inside a Viewbox displays without blurriness
    • [Unity] Improved error messages when building resources
    • [Unity] An error is shown when executing on a platform whose resource cache was not built
    • [Unity] Many small fixes that improve Unity stability
    • Fixed: Offscreen atlas algorithm giving negatives values and crashing sometimes
    • Fixed: Masking problems that were causing scrollviewers clipping issues
    • Fixed: sdcard accessing problems solved in android
    • Fixed: [Unity] Problems with properties in C# on classes extending NoesisGUI
    • Fixed: [Unity] TextBox.AcceptsReturn not working
     
  39. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Either I missed it or there is no link to the Unity Feedback request to make NoesisGUI Unity's "new" GUI. If NoesisGUI was directly integrated into the engine, it would also be available in the Web player which would make it a lot lot lot more useful (WebGL may be a possible alternative somewhere in a distant future but I don't think the Web player will disappear any time soon and most likely it will be the preferable platform for Web for a very very long time).

    So ... anyways - here's the link ... now vote like crazy:

     
  40. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    I'm only just getting started using this, but so far NoesisGUI is hitting all the right notes. Thanks!

    I did get the idea that you could hide some of the boilerplate when extending components, so I thought I'd drop the idea here. How about replacing this:

    Code (csharp):
    1.  
    2. public class Cell : Noesis.BaseComponent
    3. {
    4.     private HandleRef swigCPtr;
    5.  
    6.     public string player
    7.     {
    8.         set { mPlayer = value; }
    9.         get { return mPlayer; }
    10.     }
    11.     private string mPlayer;
    12.  
    13.     public ToggleButton btn
    14.     {
    15.         set { mBtn = value; }
    16.         get { return mBtn; }
    17.     }
    18.     private ToggleButton mBtn;
    19.  
    20.     public static void Register()
    21.     {
    22.     }
    23.  
    24.     public Cell(IntPtr cPtr, bool cMemoryOwn)
    25.         : base(cPtr, cMemoryOwn)
    26.     {
    27.         swigCPtr = new HandleRef(this, cPtr);
    28.     }
    29.  
    30.     public Cell()
    31.         : this(Noesis.Extend.New(typeof(Cell)), true)
    32.     {
    33.         Noesis.Extend.Register(typeof(Cell), swigCPtr.Handle, this);
    34.     }
    35.  
    36.     public override void Dispose()
    37.     {
    38.         lock (this)
    39.         {
    40.             if (swigCPtr.Handle != IntPtr.Zero)
    41.             {
    42.                 if (swigCMemOwn)
    43.                 {
    44.                     swigCMemOwn = false;
    45.                     if (Noesis.Kernel.IsInitialized())
    46.                     {
    47.                         Noesis.Extend.Delete(typeof(Cell), swigCPtr.Handle);
    48.                     }
    49.                 }
    50.                 swigCPtr = new HandleRef(null, IntPtr.Zero);
    51.             }
    52.             GC.SuppressFinalize(this);
    53.             base.Dispose();
    54.         }
    55.     }
    56. };
    57.  
    with something like the following:

    Code (csharp):
    1.  
    2. /* The boilerplate of registering types and instances can be hidden in your base classes
    3. by using generics. You could even get rid of the type argument <TComponent> by using
    4. reflection to find the most concrete type before registering. */
    5. public class BaseComponent<TComponent> : BaseComponent where TComponent : BaseComponent
    6. {
    7.     private HandleRef swigCPtr;
    8.    
    9.     public BaseComponent(IntPtr cPtr, bool cMemoryOwn)
    10.         : base(cPtr, cMemoryOwn)
    11.     {
    12.         swigCPtr = new HandleRef(this, cPtr);
    13.     }
    14.  
    15.     public BaseComponent()
    16.         : this(Noesis.Extend.New(typeof(TComponent)), true)
    17.     {
    18.         Noesis.Extend.Register(typeof(TComponent), swigCPtr.Handle, this);
    19.     }
    20.  
    21.     public override void Dispose()
    22.     {
    23.         lock (this)
    24.         {
    25.             if (swigCPtr.Handle != IntPtr.Zero)
    26.             {
    27.                 if (swigCMemOwn)
    28.                 {
    29.                     swigCMemOwn = false;
    30.                     if (Kernel.IsInitialized())
    31.                     {
    32.                         Noesis.Extend.Delete(typeof(TComponent), swigCPtr.Handle);
    33.                     }
    34.                 }
    35.                 swigCPtr = new HandleRef(null, IntPtr.Zero);
    36.             }
    37.             GC.SuppressFinalize(this);
    38.             base.Dispose();
    39.         }
    40.     }
    41. }
    42.  
    43. /* Extending your classes then simply becomes a matter of: */
    44. public class Cell : BaseComponent<Cell>
    45. {
    46.     public string player
    47.     {
    48.         set { mPlayer = value; }
    49.         get { return mPlayer; }
    50.     }
    51.     private string mPlayer;
    52.  
    53.     public ToggleButton btn
    54.     {
    55.         set { mBtn = value; }
    56.         get { return mBtn; }
    57.     }
    58.     private ToggleButton mBtn;
    59.  
    60.     public static void Register()
    61.     {
    62.     }
    63. } // Note: C# doesn't require a semicolon at the end of class definitions
    64.  
    Which is to say, you can probably hide a lot of the low-level stuff using generics, which makes extending your classes easier and less error-prone.

    If Unity users will not be using the BaseComponent(IntPtr cPtr, bool cMemoryOwn) constructor explicitely I would also suggest removing it or making it private.

    There might be a whole bunch of edge conditions I'm forgetting though. I just really dislike boilerplate. :)
     
    Last edited: Sep 14, 2013
  41. ai_enabled

    ai_enabled

    Joined:
    Sep 16, 2013
    Posts:
    15
    Tinus, it's right advice. We already do it in our project when the NoesisGUI 1.0 was released. Now we have nearly hundred controls, thanks to generics :). We have created generic classes for Control, UserControl and BaseComponent (for using in Collections) and Resharper file templates to easily add new derived classes. It helps much, but it's still require to write some extra-code for control constructor ("IntPtr cPtr, bool cMemoryOwn", and empty one), for UserControl registration (override metadata path to XAML-file - it looks redundant because we always place CS-classes near XAML's) and dependency properties. Ugly... but it's reasonable price to pay for using so powerful UI framework!
     
  42. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    Hi Tinus, we are working to provide a clean C# API, which doesn't require any boilerplate for extending Noesis classes. We will try to give users an API as close to WPF as we can.

    Meanwhile, using generics as you suggested is a great option to avoid writing to much boilerplate code. Thanks for sharing it with the rest of users.
     
  43. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Yes, the metadata to the xaml seems redundant if the .cs and .xaml are next to each other and with the same. I wonder if we could get automatically the name of the current .cs to get the xaml filenae. Something like this:

    http://stackoverflow.com/questions/6369184/print-the-source-filename-and-linenumber-in-c-sharp

    Although that is a big hack that probably won't work in Unity...

    PS: your game looks amazing. We love the way you are using NoesisGUI

    http://atomictorch.com/
     
  44. chillypacman

    chillypacman

    Joined:
    Oct 1, 2011
    Posts:
    71
    Hi There,

    Is it possible to dynamically add NoesisGUIPanel components at runtime through scripts? Something like:

    void Start()
    {
    NoesisGUIPanel panel = gameObject.AddComponent<NoesisGUIPanel>();
    panel._xaml = myXamlFile;
    }

    I've tried doing that but it doesn't work hehe.


    Another question: Is it possible to create a xaml usercontrol then re-use it in other xaml layouts in Unity? I've tried and it hasn't worked, this is what I'm trying:

    MyControl.xaml:

    MyLayout.xaml:

    The problem is if I use a C# class as codebehind it works in expression blend in Visual Studio but Unity cannot compile that C# file... kind of problematic.
     
    Last edited: Sep 22, 2013
  45. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    Hi,

    I see that you bought NoesisGUI. My advice is that you register yourself at our forums (http://forums.noesisengine.com/) and email us the order number from the asset store. That way you will be able to download the latest version of NoesisGUI (by the way we released 1.0.4 yesterday and that version is yet no available from the asset store) and some extras like the NoesisGUI SDK.

    Our commercial users can report us bugs at http://bugs.noesisengine.com/ and we give high priority for everything that is coming from the bugtracker. We are releasing a new version each two weeks approximately.

    If you need support for NoesisGUI, it is better if you use the support forum.

    About your questions:

    1. I think we didn't test that scenario. So it may be give problems. Please open a post in our forum to discuss this.

    2. Yes, what you are asking can be done (if not, usercontrols would be useless). I am not in front of a computer right now but the sample Primitives that comes with our unitypackage does that. And if I remember right, our unity tutorial comments about it. If you continue with problems please post in our forum. We will try to help you.

    Thanks!
     
  46. sfernandez

    sfernandez

    Joined:
    Feb 14, 2012
    Posts:
    104
    Hi, Visual Studio or Expression Blend C# classes can't be used directly in Unity. Following instructions from First steps with NoesisGUI in Unity tutorial in our documentation, you can convert these classes to Noesis compatible code. Using your example I wrote the following code for your MyControl.Control class:

    Code (csharp):
    1. using UnityEngine;
    2. using System;
    3. using System.Runtime.InteropServices;
    4.  
    5. namespace MyControl
    6. {
    7. public class Control : Noesis.UserControl
    8. {
    9.     private HandleRef swigCPtr;
    10.  
    11.     // This function is required (even if empty) to register the class in NoesisGUI automatically,
    12.     // so objects of this type can be created when XAML is parsed
    13.     public static void Register()
    14.     {
    15.         // Here you indicate the xaml file where this UserControl defines its contents
    16.         Noesis.UserControl.SourceProperty.OverrideMetadata(typeof(Control),
    17.             new Noesis.PropertyMetadata(
    18.                 "Assets/NoesisGUI/Samples/_Tests/UserControls/MyControl.xaml"));
    19.     }
    20.  
    21.     public Control(IntPtr cPtr, bool cMemoryOwn)
    22.         : base(cPtr, cMemoryOwn)
    23.     {
    24.         swigCPtr = new HandleRef(this, cPtr);
    25.     }
    26.  
    27.     public Control()
    28.         : this(Noesis.Extend.New(typeof(Control)), true)
    29.     {
    30.         Noesis.Extend.Register(typeof(Control), swigCPtr.Handle, this);
    31.     }
    32.  
    33.     public override void Dispose()
    34.     {
    35.         lock (this)
    36.         {
    37.             if (swigCPtr.Handle != IntPtr.Zero)
    38.             {
    39.                 if (swigCMemOwn)
    40.                 {
    41.                     swigCMemOwn = false;
    42.                     if (Noesis.Kernel.IsInitialized())
    43.                     {
    44.                         Noesis.Extend.Delete(typeof(Control), swigCPtr.Handle);
    45.                     }
    46.                 }
    47.                 swigCPtr = new HandleRef(null, IntPtr.Zero);
    48.             }
    49.             GC.SuppressFinalize(this);
    50.             base.Dispose();
    51.         }
    52.     }
    53.  
    54.     // Initialize the user control here
    55.     public void OnPostInit()
    56.     {
    57.     }
    58. }
    59. }
    60.  
    After adding this script, and fixing a typo error you have in both xaml files (you forgot the ':x' in the second namespace definition: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"), I was able to play your MyLayout.xaml interface with no problem.
     
  47. chillypacman

    chillypacman

    Joined:
    Oct 1, 2011
    Posts:
    71
    That worked perfectly, thank you so much!
     
  48. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    We are working to simplify the API to extend NoesisGUI in c#. As soon as this is finished (soon) and the API is stabilized we are going to create a community gallery to share spinets and user controls. To help XAML newcomers and allow sharing of ideas between users.
     
  49. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    312
    NoesisGUI v1.0.4

    >> Buy from Asset Store

    • New platform: Linux, native runtime and Unity standalone player
    • New 64 bits platforms for OS X and Windows
    • Size of runtimes considerably reduced
    • Default style modified to reflect local properties set in controls. For example <Button Background="Red"/> now renders a button with a red background, instead of using the default color for the style
    • New sample in ControlGallery showing buttons with different styles
    • Implemented Mouse.GetPosition() relative to an element
    • [Unity] VisualTreeHelper.HitTest exposed to Unity
    • [Unity] HitTesting for render texture using RaycastHit.textureCoord. GameObject needs a valid MeshCollider. Unity tutorial updated
    • Fixed: Fixed ListBox crashing when changing items that use ItemTemplate
    • Fixed: When changing style of the inner ScrollViewer of a TextBox internal TextBoxView was not correctly set and measured
    • Fixed: TextBox clipping was lost when the style of the internal ScrollViewer changed
    • Fixed: TextBox was not updating the insertion point and selection indexes when Text property was set through code
    • Fixed: [Unity] UV coordinates were vertically flipped with respect to Unity convention
    • Fixed: [Unity] Null string objects in unity are now treated as string.Empty
    • Fixed: [Unity] Improved stability when errors happening in native
    • Fixed: [Unity] Fixed a rare crash when resizing Unity standalone
     
  50. fversnel

    fversnel

    Joined:
    Jan 7, 2013
    Posts:
    6
    Hi,

    I've just started using NoesisGui and have some problems with the RenderTexture functionality.
    In v.1.0.4 whenever I programmatically change the FontSize or FontWeight of a TextBlock then the old version of the TextBlock stays visible just like the bug in v1.0.3 where SetText would not clear the text in the TextBlock before updating. When rendering directly to a Camera none of these problems exist.

    Cheers,
    Frank