Hello,
I'll share how we at
Dreamloop handle our workflow with Noesis and Unity.
We use Blend to only edit .xaml files and Visual Studio to edit .cs files.
First we obviously in Blend make a new project. We put this new project to root of unity project folder, same location where "assets" folder is located. Disable "create directory for solution"
When new project is made, we cut everything from this new Blend project folder to the root of Unity project folder. so for example in above image, new folder names GameUI will be made at root of Unity project folder, cut everything from there and paste to the root of your Unity project folder. Open Blend and open GameUI project.
Now we have Blend project with access to all of our Unity project files if we want so.
Click Show All Files in blend solution explorer to see Assets folder. There you can see all of your Unity files and add them to your Blend project by right clicking and choosing "Include in Project"
Now example from our real project.
We already used
Strange IoC in our project, so it was quite simple to add MVVM architecture on top of that. Here is a graph of how our hybrid MVVM-MVCS. We use MVVM for all UI related.
UIView our .xaml files.
UICode is the code behind, .xaml.cs files.
ManagedView is our StrangeIoC View which communicates with all Strange IoC related code.
XamlHelper (at the right side of that image) is our all kind of xaml stuff and often used UI interactions for example window dragging with mouse, invokes, converters etc.
Here I will show you part of one of our .xaml.cs code of one UserControl, our ArenaModeWindow UI.
#if UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS || UNITY_WINRT_8_1
#define UNITY
#endif
#if UNITY
using Assets.GloryAssets.Cok_Xaml.Editors.Views;
using Assets.GloryAssets.Scripts.Xaml.Commands;
using Noesis;
using System.Collections;
using UnityEngine;
using System;
using System.Windows.Input;
using Assets.GloryAssets.Scripts.GUI.XamlHelpers;
using Assets.GloryAssets.Scripts.Arenamode.Views;
#else
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
#endif
namespace Assets.GloryAssets.Scripts.GUI.UserControls
{
/// <summary>
/// Interaction logic for ArenaModeWindow.xaml
/// </summary>
#if UNITY
[UserControlSource("Assets/GloryAssets/Cok_Xaml/Arena/ArenaModeWindow.xaml")]
#endif
public partial class ArenaModeWindow : UserControl
{
#if UNITY
FrameworkElement _root;
ArenaModeView _view;
FrameworkElement _Bar;
public DelegateCommand ActionButtonClickedCommand { get; private set; }
public DelegateCommand NextTargetButtonClickedCommand { get; private set; }
public DelegateCommand PreviousTargetButtonClickedCommand { get; private set; }
public DelegateCommand DebugLocationCommand { get; private set; }
public DelegateCommand ContinueButtonClickedCommand { get; private set; }
public ICommand EnterCommand { get; private set; }
public ICommand ExitCommand { get; private set; }
public ArenaModeWindow()
{
ActionButtonClickedCommand = new DelegateCommand(OnActionButtonClicked);
NextTargetButtonClickedCommand = new DelegateCommand(OnNextTargetButtonClicked);
PreviousTargetButtonClickedCommand = new DelegateCommand(OnPreviousTargetButtonClicked);
ContinueButtonClickedCommand = new DelegateCommand(OnContinueButtonClickedCommand);
DebugLocationCommand = new DelegateCommand(debugLocation);
EnterCommand = new DelegateCommand(OnEnter);
ExitCommand = new DelegateCommand(OnExit);
this.Initialized += OnInitialized;
this.InitializeComponent();
}
private void OnContinueButtonClickedCommand(object o)
{
_view.OnContinueButtonClicked();
}
private void OnEnter(object o)
{
_view.OnMouseOverTurnTrackerElement((int)o);
}
private void OnExit(object o)
{
_view.OnMouseExitTurnTrackerElement((int)o);
}
private void OnActionButtonClicked(object obj)
{
_view.ActionButtonClicked((int)obj);
}
private void OnNextTargetButtonClicked(object obj)
{
_view.NextTargetButtonPressed();
}
private void OnPreviousTargetButtonClicked(object obj)
{
_view.PreviousTargetButtonPressed();
}
private void debugLocation(object obj)
{
FrameworkElement element = (FrameworkElement)obj;
Debug.Log(Noesis.Canvas.GetLeft(element));
}
private void OnInitialized(object sender, Noesis.EventArgs e)
{
_view = Camera.main.GetComponent<ArenaModeView>();
_root = (UserControl)FindName("root");
_root.DataContext = _view;
_view.root = _root;
}
#endif
}
As you can see, Blend will only see lines which defines our Class and some includes. All other code is completely out of Blend's reach. We only want Blend to be able to build solution without errors so this enables us to do that.
At initialization we set our Xaml's datacontext to our StrangeIoC View.
We are quite happy with this workflow.