Workflow to use Unity asset types in Blend unclear
Posted: 23 Apr 2021, 19:44
I'm sorry for my tons of questions but I am really having a hard time understanding how to use Noesis in combination with Unity. The integration is really rough for me.
Here's what I'm trying to do. I'm trying to create a scene that is basically a map editor for a 2D game. So I have a 2D hexagon grid as the normal Unity part of the scene which registers clicks and all that. That works fine.
Now... I use Noesis to create the UI, so far a very simple top bar with just a combobox and togglebutton to start painting terrain. The painting is Unity, that's not important. That parts works anyway, I'm just writing that so you know what my usecase is.
The parts that I cannot get to work are these:
A) Databinding
So I'm trying to select a TerrainType to paint from a ComboBox. TerrainType is a custom asset deriving from ScriptableObject. It has a property of type RandomTile which is derived from the unity type Tile and has a List of Sprites which are assigned in the inspector and then one is selected randomly for display on each grid position where the terraintype is used.
What I want to do is create a datatemplate for my combobox that has the name of the asset, a simple string "Forest" "Hills" whatever. I'm not worrying about localization right now.
And below that text I want the first of the list of Sprites that the Tile of the TerrainType defines. Or rather the texture of that sprite.
So I'm databinding like this:
Now this doesn't work. I'm assuming I'm correct in databinding the image source to the texture and not the sprite itself (which doesn't work either).
I'm reading that xaml assets need to have dependencies. I'm not exactly sure how that is supposed to work. I cannot specify what the textures are, these assets are references by a Zenject dependency injection installer on another gameobject and injected into the viewmodel. Referencing them directly in the Xaml asset beats the purpose of layer separation. The view cannot know which textures it will have to display. That depends on the databinding. The TerrainTypes ARE referenced in the scene on an object, but the XAML assets shows in the inspector that it doesn't know about any dependencies. At this point I have no clue how to get this to work. Manually specifying the dependencies is an absolute no-go. That beats the entire purpose of using MVVM in the first place. I want the View to display a databound texture, no matter what it is. If that doesn't work, then I can forget using Noesis for this altogether.
B) Blendability
I still have a massive problem understanding how this Blend Workflow is supposed to work.
To make all this blendable I basically need to give every viewmodel an interface and create a completely separate DesignViewModel for the blend project.
So far so good, that's fine, I do that in WPF sometimes also, depending on how important design time is.
However I have ZERO clue how this is supposed to work in Unity. I am databinding against unity types. Against assets deriving from UnityEngine base classes.
That means the design ViewModels need to understand Unity including every derived type I create. But if I include those files in the blend project I end up
needing to reference tons of extensions I use in those files, like attributes that get used in the inspector, other extensions that I might use for Unity productivity purposes,
logging stuff etc etc.
I cannot simply wrap all that in #if NOESIS clauses or my code will be unreadable and clutterd with UI specific clauses in modules that have zero to do with UI.
So how exacty am I supposed to make these design time viewmodels in a WPF/Blend project? I don't understand how that is supposed to work?
For example if I bind against Tile, a Unity Base class, I cannot create an interface for that to replace it with a stub. The XAML will have the namespace for use in the datatemplate as the DataType. So I cannot just fake it. Even worse if I want to bind a texture. I cannot create a fake texture in a WPF application. How am I supposed to preview that for design time/blendability?
I can see how Noesis works in C# world but I still don't understand how you do this together with unity. A WPF application doesn't understand Unity types and I have no idea
how to write design time data for my use cases since I bind against those Unity types to display stuff...
I'd appreciate some insight here from people who do this extensively. The Blendability workflow and the use of Unity Types are the biggest hurdle so far for me.
That integration point Noesis<->Unity really gives me headaches and makes it hard for me to remain productive.
I'm trying to use Noesis because frankly the UI solutions by Unity itself so far have been one terrible choice after another. The newest UI Elements is a mess also in terms of productivity in my opinion and XAML is far superior to their customXML+customCSS approach but that's beside the point.
But all the productivity and flexibility I'm hoping to get out of this has so far not materialized. The XAML part is easy for me. I'm a senior WPF design engineer and I'm developing WPF controls and entire UIs for a living so I know my way around that side of things no problem. But as soon as the unity integration gets involved everything falls apart for me and I always run against walls. So sorry if my posts sound frustrating. I think Noesis is an amazing thing and Unity should have bought or contracted this instead of all their half baked solutions. I just need help in understanding how this is supposed to smoothly integrate. To me it feels incredibly unintuitive and I run into hurdles at almost every step. So far I've invested 2 weeks in trying to get a simple toolbar to work and setting up a basic application framework.
I appreciate any help someone can give me.
Here's what I'm trying to do. I'm trying to create a scene that is basically a map editor for a 2D game. So I have a 2D hexagon grid as the normal Unity part of the scene which registers clicks and all that. That works fine.
Now... I use Noesis to create the UI, so far a very simple top bar with just a combobox and togglebutton to start painting terrain. The painting is Unity, that's not important. That parts works anyway, I'm just writing that so you know what my usecase is.
The parts that I cannot get to work are these:
A) Databinding
So I'm trying to select a TerrainType to paint from a ComboBox. TerrainType is a custom asset deriving from ScriptableObject. It has a property of type RandomTile which is derived from the unity type Tile and has a List of Sprites which are assigned in the inspector and then one is selected randomly for display on each grid position where the terraintype is used.
What I want to do is create a datatemplate for my combobox that has the name of the asset, a simple string "Forest" "Hills" whatever. I'm not worrying about localization right now.
And below that text I want the first of the list of Sprites that the Tile of the TerrainType defines. Or rather the texture of that sprite.
So I'm databinding like this:
Code: Select all
<DataTemplate DataType="assets:TerrainType">
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{Binding Name, Mode=OneWay}" />
<Image HorizontalAlignment="Center" Source="{Binding Tile.Sprites[0].texture, Mode=OneWay}" />
</StackPanel>
</DataTemplate>
I'm reading that xaml assets need to have dependencies. I'm not exactly sure how that is supposed to work. I cannot specify what the textures are, these assets are references by a Zenject dependency injection installer on another gameobject and injected into the viewmodel. Referencing them directly in the Xaml asset beats the purpose of layer separation. The view cannot know which textures it will have to display. That depends on the databinding. The TerrainTypes ARE referenced in the scene on an object, but the XAML assets shows in the inspector that it doesn't know about any dependencies. At this point I have no clue how to get this to work. Manually specifying the dependencies is an absolute no-go. That beats the entire purpose of using MVVM in the first place. I want the View to display a databound texture, no matter what it is. If that doesn't work, then I can forget using Noesis for this altogether.
B) Blendability
I still have a massive problem understanding how this Blend Workflow is supposed to work.
To make all this blendable I basically need to give every viewmodel an interface and create a completely separate DesignViewModel for the blend project.
So far so good, that's fine, I do that in WPF sometimes also, depending on how important design time is.
However I have ZERO clue how this is supposed to work in Unity. I am databinding against unity types. Against assets deriving from UnityEngine base classes.
That means the design ViewModels need to understand Unity including every derived type I create. But if I include those files in the blend project I end up
needing to reference tons of extensions I use in those files, like attributes that get used in the inspector, other extensions that I might use for Unity productivity purposes,
logging stuff etc etc.
I cannot simply wrap all that in #if NOESIS clauses or my code will be unreadable and clutterd with UI specific clauses in modules that have zero to do with UI.
So how exacty am I supposed to make these design time viewmodels in a WPF/Blend project? I don't understand how that is supposed to work?
For example if I bind against Tile, a Unity Base class, I cannot create an interface for that to replace it with a stub. The XAML will have the namespace for use in the datatemplate as the DataType. So I cannot just fake it. Even worse if I want to bind a texture. I cannot create a fake texture in a WPF application. How am I supposed to preview that for design time/blendability?
I can see how Noesis works in C# world but I still don't understand how you do this together with unity. A WPF application doesn't understand Unity types and I have no idea
how to write design time data for my use cases since I bind against those Unity types to display stuff...
I'd appreciate some insight here from people who do this extensively. The Blendability workflow and the use of Unity Types are the biggest hurdle so far for me.
That integration point Noesis<->Unity really gives me headaches and makes it hard for me to remain productive.
I'm trying to use Noesis because frankly the UI solutions by Unity itself so far have been one terrible choice after another. The newest UI Elements is a mess also in terms of productivity in my opinion and XAML is far superior to their customXML+customCSS approach but that's beside the point.
But all the productivity and flexibility I'm hoping to get out of this has so far not materialized. The XAML part is easy for me. I'm a senior WPF design engineer and I'm developing WPF controls and entire UIs for a living so I know my way around that side of things no problem. But as soon as the unity integration gets involved everything falls apart for me and I always run against walls. So sorry if my posts sound frustrating. I think Noesis is an amazing thing and Unity should have bought or contracted this instead of all their half baked solutions. I just need help in understanding how this is supposed to smoothly integrate. To me it feels incredibly unintuitive and I run into hurdles at almost every step. So far I've invested 2 weeks in trying to get a simple toolbar to work and setting up a basic application framework.
I appreciate any help someone can give me.