Heia Samahi
Topic Author
Posts: 8
Joined: 28 Mar 2018, 09:21

[Unity][Bug?] Missing xaml exception - But it works... sort of...

05 Apr 2018, 16:41

Hello,

I've run into an annoying bug.
Every time I restart the unity editor. All non-root XAML "paths" files "breaks". And, I can build but not run the build.
Only when I retrigger the XAML import likely by adding a space in the XAML, it works again.

Noesis throws an exception which usually happens only with missing XAML. But, the XAMLs works if I retrigger the import. It looks like that NoesisXaml.cs loss some important data.
It happens currently only to XAMLs who are nested in the root XAML.


Executable small demo project

http://www.mediafire.com/file/ltajyir5c ... UI_Bug.rar
If you have a problem with rars. Let me know, and I will upload it as a zip.

Open the master scene under CaveDigger/Scenes/
I hope you can it reproduce and it's not just my pc. I mean, I could hardly live with that problem in the editor ... nah probably not. But Runtime? I think you know what I mean.

I post this here because I am not sure if your bug tracker is ready to use... looks so empty^^ and I need attention.

Video demonstration

https://www.youtube.com/watch?v=xhjz9OT ... HbDo3AVdlQ
  • 0:00-0:30 Working GUI
  • 0:30 Restarting Editor
  • 0:45 Not working anymore
  • 1:00 Retrigger XAML import.
  • 1:15 Error changed from ChunkEditView.xaml to TileEditView.xaml
  • 1:40 After several reimports .. GUI working again.
  • 1:50 Funny thing: Normally I must retriggering the DialogBasic & DialogList XAML as well. But not this time.
  • 2:00-2:30 Restart Unity
  • 2:30 Retriggering, just the Root Xaml, does not help at all.
  • 2:50 Showing Noesis View Component
Versions
  • Unity Version 2017.4.0f1 (b5bd171ee9ba)
  • Noesis Version 2.1.0f1
Exception
NoesisException: Xaml not found 'Assets/CaveDigger/UI/DialogSystem/DialogListView.xaml'
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.GUI.Noesis_LoadXaml_ (System.String xaml) (at Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs:275)
Noesis.GUI.LoadXaml (System.String xaml) (at Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs:125)
HeiKyu.Framework.XAML.DialogSystem.DialogList..ctor (HeiKyu.Framework.XAML.DialogSystem.DialogServices services, System.String title, System.String text, System.String buttonOk, System.String buttonCancel) (at Assets/CaveDigger/UI/DialogSystem/DialogList.cs:55)
HeiKyu.Framework.XAML.DialogSystem.DialogList..ctor (HeiKyu.Framework.XAML.DialogSystem.DialogServices services, System.String title, System.String text, System.String buttonOk, System.String buttonCancel, System.Action`1 buttonOkAction, System.Action`1 buttonCancelAction) (at Assets/CaveDigger/UI/DialogSystem/DialogList.cs:22)
CaveDigger.Scripts.UI.MainEditorViewModel.OnButtonClickMenuBarFileLoad () (at Assets/CaveDigger/Scripts/UI/MainEditorViewModel.cs:406)
CaveDigger.Scripts.UI.MainEditorViewModel.<Start>m__5 (System.Object o) (at Assets/CaveDigger/Scripts/UI/MainEditorViewModel.cs:153)
CaveDigger.Scripts.UI.DelegateCommand.Execute (System.Object parameter) (at Assets/CaveDigger/Scripts/UI/DelegateCommand.cs:42)
Noesis.Extend.CommandExecute (IntPtr cPtr, IntPtr paramType, IntPtr paramPtr) (at Assets/NoesisGUI/Plugins/API/Core/NoesisExtend.cs:1874)
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.View.Noesis_View_MouseButtonUp_ (HandleRef view, Int32 x, Int32 y, Int32 button) (at Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:457)
Noesis.View.MouseButtonUp (Int32 x, Int32 y, MouseButton button) (at Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:161)
NoesisView.ProcessEvent (UnityEngine.Event ev, Boolean enableKeyboard, Boolean enableMouse, Boolean emulateTouch) (at Assets/NoesisGUI/Plugins/NoesisView.cs:878)
NoesisView.OnGUI () (at Assets/NoesisGUI/Plugins/NoesisView.cs:950)

Regards,

Heia Samahi
Last edited by Heia Samahi on 11 Apr 2018, 10:28, edited 1 time in total.
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

07 Apr 2018, 14:58

As explained in the Unity tutorial, non roots XAMLs need to be referenced somewhere or Unity will discard them. You can use the Preloaded Xamls list for that purpose.

We are working in an automatic way to detect this (by inspecting the XAML and detecting user controls) but it is not going not be a perfect solution. So it is better if you do it manually.
 
Heia Samahi
Topic Author
Posts: 8
Joined: 28 Mar 2018, 09:21

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

07 Apr 2018, 16:29

Hello,

This is not really explained on the tutorial page. This should be described in more detail in the documentation. Because I read this.

If I want to load XAML from the code, yes, this is explained and looks very familiar in the Unity environment.

But I thought wrong. I thought, I don't need to do that because I don't load XAML from code.
Why did I think that? That non-root XAML is embedded in the root XAML.
But yes, I understand it now. Noesis "ignore" that and don't reference the sub XAML.assets in editor time and don't save the reference in the root XAML.asset. Of course, then it's not possible that Unity holds the reference at runtime.

I read about the problem already in another thread. But I didn't expect my problem is the same.

So, sorry for the fussiness and thank you for your time. I haven't tested it yet. But, it sounds already that I was the problem.

I mark that thread as answered, as soon as I have tested it.

Thank you.
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

09 Apr 2018, 19:10

You are totally right, the documentation is not clear about this, sorry about it. We will fix it and also will try to autodetect XAML dependencies when using UserControls.

Thanks for your feedback and your awesome repro project and included video.
 
Heia Samahi
Topic Author
Posts: 8
Joined: 28 Mar 2018, 09:21

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

10 Apr 2018, 00:06

Thanks for your feedback and your awesome repro project and included video.
Thanks, but I am still struggling.

What do I write into the InitializeComponent() method in a non-root XAML?
I mean, it's a UserControl. It has only on the XAML side a reference.
In the XAML it looks like this:
<dialogsystem:DialogView x:Name="DialogView"/>
But, now, what I must write in the DialogView.cs?
I have tried following things:

Method 1: Of course this work only for root xamls
Noesis.GUI.LoadComponent(this, "Assets/CaveDigger/Resources/UI/DialogSystem/DialogView.xaml");
Method 2: This should work? Does not!
NoesisXaml xaml = (NoesisXaml)UnityEngine.Resources.Load("UI/DialogSystem/DialogView", typeof(NoesisXaml))
xaml.LoadComponent(this);  
Throws:
Exception: Unexpected empty XAML. Please reimport again
NoesisXaml.LoadComponent (object) (at Assets/NoesisGUI/Plugins/NoesisXaml.cs:38)
HeiKyu.Framework.XAML.DialogSystem.DialogView.InitializeComponent () (at Assets/CaveDigger/Resources/UI/DialogSystem/DialogView.xaml.cs:32)

Method 3: Total failure. Deathlock into infinitely load-cycle. But makes sense. It loads the XAML with the cs file. What ends up here again.
NoesisXaml xaml = (NoesisXaml)UnityEngine.Resources.Load("UI/DialogSystem/DialogView", typeof(NoesisXaml))
Content = xaml.Load();
Unfortunately, exactly this sample is not available for Unity, which might have given me an answer.
https://github.com/Noesis/Tutorials/tre ... serControl

So what do I wrong?
You wrote in the section "Loading XAML by Code"
Problem with this approach is that it is not compatible with WPF.
Mean this, it's currently not possible?
Also that I just insert a UserControl via XAML? Or is there a solution?

I mean, I could load the UserControls from hand (in the root XAML class) and set the Content into placeholders. But it's more a ducktape solution.

Regards,

Heia Samahi
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

10 Apr 2018, 16:35

Thanks, but I am still struggling.

What do I write into the InitializeComponent() method in a non-root XAML?

I mean, it's a UserControl. It has only on the XAML side a reference.
In the XAML it looks like this:
<dialogsystem:DialogView x:Name="DialogView"/>
The recommended way right now is writing this in the InitializeComponent() (by the way we recommend following the Blend convention of naming the class DialogView.xaml.cs to indicate it is the code-behind):
Noesis.GUI.LoadComponent(this, "Assets/CaveDigger/Resources/UI/DialogSystem/DialogView.xaml");
And after that, adding DialogView.xaml to the preloaded XAMLs list commented in the tutorial. Or if you don't want to use that list, then you need to reference in a similar way the XAML in one of your scripts. Note that, this last step won't be needed in future versions once we detect automatically dependencies to UserControls.
 
Heia Samahi
Topic Author
Posts: 8
Joined: 28 Mar 2018, 09:21

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

11 Apr 2018, 10:27

by the way we recommend following the Blend convention of naming the class DialogView.xaml.cs to indicate it is the code-behind
Thanks, I know that. I just forgot it to write it here.


I will use the list. I thought there is maybe another way. But it would be nice if the autodetect comes in near future.
And I found it very strange that Method 2. does not work.

But if someday I change my other project with mod support to noesis, I just have to write myself a XAML importer that can do that during the runtime, for the mod UI's. Then the method will work too, I think.
That's the good thing, the whole XAML / Texture / Font Processor comes with source code. Thanks for that. It would be annoying to decompile a DLL for that.

Regards,

Heia Samahi
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

13 Apr 2018, 13:15

I will use the list. I thought there is maybe another way. But it would be nice if the autodetect comes in near future.
Yes, we are working on it.
And I found it very strange that Method 2. does not work.
It should work, are you sure you moved both the .xaml and corresponding .asset inside a /Resources/ folder? I will try to reproduce the issue as soon as possible.
 
Heia Samahi
Topic Author
Posts: 8
Joined: 28 Mar 2018, 09:21

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

15 Apr 2018, 09:22

It should work, are you sure you moved both the .xaml and corresponding .asset inside a /Resources/ folder? I will try to reproduce the issue as soon as possible.
Yes, the whole UI folder is under Resources. Unity seems not the problem.
This is working. I get the NoesisXaml from Resources folder.
NoesisXaml xaml = (NoesisXaml)UnityEngine.Resources.Load("UI/Views/Controls/ChunkEditView", typeof(NoesisXaml));
And here it throws the exception:
xaml.LoadComponent(this);
Exception: Unexpected empty XAML. Please reimport again
NoesisXaml.LoadComponent (object) (at Assets/NoesisGUI/Plugins/NoesisXaml.cs:38)
HeiKyu.Framework.XAML.DialogSystem.DialogView.InitializeComponent () (at Assets/CaveDigger/Resources/UI/DialogSystem/DialogView.xaml.cs:32)
Complete File of the non-root XAML or better name of the UserControl that is embedded in the root XAML:
#if UNITY_5_3_OR_NEWER
#define NOESIS
using Noesis;

#else
using System.Windows.Controls;
#endif


namespace CaveDigger.UI.Views.Controls
{
    /// <summary>
    /// Interaktionslogik für ChunkEditView.xaml
    /// </summary>
    public partial class ChunkEditView : UserControl
    {
        public ChunkEditView()
        {
            InitializeComponent();
        }

#if NOESIS
        private void InitializeComponent()
        {
            //GUI.LoadComponent(this, "Assets/CaveDigger/Resources/UI/Views/Controls/ChunkEditView.xaml");
            NoesisXaml xaml = (NoesisXaml)UnityEngine.Resources.Load("UI/Views/Controls/ChunkEditView", typeof(NoesisXaml));
            xaml.LoadComponent(this);
        }
#endif
    }
}
But probably its better if you look yourself, especially when you say it should work. Maybe I do something wrong. But it seems odd because I don't find any error.
New, updated demo project.
http://www.mediafire.com/file/tr7tua3zg ... ug%202.rar
(Open the master scene under CaveDigger/Scene/)
 
User avatar
EspiraPhoenix
Posts: 1
Joined: 30 Mar 2018, 14:04
Location: Australia
Contact:

Re: [Unity][Bug?] Missing xaml exception - But it works... sort of...

21 Apr 2018, 04:51

And here it throws the exception:
xaml.LoadComponent(this);
Exception: Unexpected empty XAML. Please reimport again
NoesisXaml.LoadComponent (object) (at Assets/NoesisGUI/Plugins/NoesisXaml.cs:38)
HeiKyu.Framework.XAML.DialogSystem.DialogView.InitializeComponent () (at Assets/CaveDigger/Resources/UI/DialogSystem/DialogView.xaml.cs:32)
Hello, I'm a bit new to NoesisGUI, but I might be able to help here as I had encountered this issue too.

The exception is being thrown because of a minor bug with the IF statement inside the LoadComponent method (at Assets/NoesisGUI/Plugins/NoesisXaml.cs, line 36).

Replacing:
if (CanLoad())
into:
if (!CanLoad())
will solve the problem.

Who is online

Users browsing this forum: No registered users and 1 guest