Faerdan
Topic Author
Posts: 55
Joined: 02 Oct 2015, 09:11
Location: Galway, Ireland
Contact:

Not using MonoBehaviour for NoesisGUI in Unity

16 Oct 2015, 10:40

Hi again,


I am probably not your typical Unity developer, in that my game is written primarily in code (with minimal use of MonoBehaviour or ScriptableObject).

I have separated NoesisGUIPanel from the Monobehaviour, and instead call the relevant methods as required. This works perfectly, but it means that my code is deviating from yours (the Noesis GUI dev's), and each update I may need to revise mine.

I was wondering if you (the developers of Noesis GUI) would be interested in separating the NoesisGUIPanel from the MonoBehaviour, to allow people like me to use your code without modifying it?

My thinking on how it would work:

The current NoesisGUIPanel is renamed to NoesisGUIEntry, and has all of it's MonoBehaviour elements removed. Instead it has just the methods and properties which are required.

A new NoesisGUIPanel MonoBehaviour class is created. It creates, manages, and calls methods on a NoesisGUIEntry object. The end result is that it's behaviour to the end user does not change, but it allows programmers (like me) to easily create and manage NoesisGUIEntry objects in code, without requiring GameObjects.

NoesisGUISystem still remains as a MonoBehaviour/GameObject.


I realise this is asking for something which many do not need or want. Maybe I am the only one.

I would be happy to write the revised system if you are interested in reviewing it? I have considered and tested all of the issues, including graceful destruction.


Thanks,

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

Re: Not using MonoBehaviour for NoesisGUI in Unity

16 Oct 2015, 17:12

Hi Mark,

Thanks for sharing this. Yes, it is very interesting for us. In fact for v1.3 we want to unify the C# SDK and C# Unity API. Right now, they diverge in many points that should be unified. Besides, in v1.3 we are making a few important changes to NoesisGUIPanel so it is probably a good idea to create a new class.

So, I would say we can analyze this for v1.3, right now we can't dedicate much time for this but we can revisit this again in a few months if you want.
 
Faerdan
Topic Author
Posts: 55
Joined: 02 Oct 2015, 09:11
Location: Galway, Ireland
Contact:

Re: Not using MonoBehaviour for NoesisGUI in Unity

16 Oct 2015, 17:40

Hi Jesus,

I am delighted to hear that you will be unifying the SDK and Unity APIs.

I have happy to keep going with my MonoBehaviour-less NoesisGUIPanels, it is functioning perfectly. If you do separate them at a later stage I'll just switch to that.

This is all I need now to create a panel:
   
m_guiPanel = new NoesisGUIPanel();
m_guiPanel.Xaml = "Assets/XAML/Menus/MainMenu.xaml";
m_guiPanel.CreateRenderer();
After that NoesisGUISystem MonoBehaviour calls the required methods on the NoesisGUIPanel, until it is destroyed. NoesisGUIPanel destruction is handled gracefully using a WaitForEndOfFrame Coroutine triggered in NoesisGUISystem when Destroy is called on the panel.

There is some custom Camera logic in there too for pre and post rendering.

All of that means the whole system uses a single MonoBehaviour, NoesisGUISystem, which is managed by the code as usual.


It's a testament to the quality of your code that it was so easy to unplug the system from the MonoBehaviour.


Thanks!

Who is online

Users browsing this forum: ivan.fuertes and 1 guest