UrhoSharp Windows Support

PDF for offline use:

Let us know how you feel about this.


0/250
Thanks for the feedback!

Windows Specific Setup and Features

While Urho is a portable class library, and allows the same API to be used across the various platform for your game logic, you still need to initialize Urho in your platform specific driver, and in some cases, you will want to take advantage of platform specific features.

In the pages below, assume that MyGame is a sublcass of the Application class.

Supported architectures: only 64bit Windows.

You can see complete examples showing how to use this in our samples

Standalone Project

Creating a Project

Create a Console project, reference the Urho NuGet and then make sure that you can locate the assets (the directories containing the Data directory).

Configuring and Launching Urho

To launch your application, do this:

DesktopUrhoInitializer.AssetsDirectory = "../Assets";
new MyGame().Run();

Example

Complete example

Integrated with WPF

Creating a Project

Create a WPF project, reference the Urho NuGet and then make sure that you can locate the assets (the directories containing the Data directory).

Configuring and Launching Urho from WPF

Create a subclass of Window and configure your assets like this:

public partial class MainWindow : Window
    {
        Application currentApplication;

        public MainWindow()
        {
            InitializeComponent();
            DesktopUrhoInitializer.AssetsDirectory = @"../../Assets";
            Loaded += (s,e) => RunGame (new MyGame ());
        }

        async void RunGame(MyGame game)
        {
            var urhoSurface = new Panel { Dock = DockStyle.Fill };
            WindowsFormsHost.Child = urhoSurface;
            WindowsFormsHost.Focus();
            urhoSurface.Focus();
            await Task.Yield();
            var appOptions = new ApplicationOptions(assetsFolder: "Data")
                {
                    ExternalWindow = RunInSdlWindow.IsChecked.Value ? IntPtr.Zero : urhoSurface.Handle,
                    LimitFps = false, //true means "limit to 200fps"
                };
            currentApplication = Urho.Application.CreateInstance(value.Type, appOptions);
            currentApplication.Run();
        }
    }

Example

Complete example

Integrated with UWP

Creating a Project

Create a UWP project, reference the Urho NuGet and then make sure that you can locate the assets (the directories containing the Data directory).

Configuring and Launching Urho from UWP

Create a subclass of Window and configure your assets like this:

{
            InitializeComponent();
            GameTypes = typeof(Sample).GetTypeInfo().Assembly.GetTypes()
                .Where(t => t.GetTypeInfo().IsSubclassOf(typeof(Application)) && t != typeof(Sample))
                .Select((t, i) => new TypeInfo(t, $"{i + 1}. {t.Name}", ""))
                .ToArray();
            DataContext = this;
            Loaded += (s, e) => RunGame (new MyGame ());
        }

        public void RunGame(TypeInfo value)
        {
            //at this moment, UWP supports assets only in pak files (see PackageTool)
            currentApplication = UrhoSurface.Run(value.Type, "Data.pak");
        }
    }

Example

Complete example

Integrated with Windows.Forms

Creating a Project

Create a Windows.Forms project, reference the Urho NuGet and then make sure that you can locate the assets (the directories containing the Data directory).

Configuring and Launching Urho from Windows.Forms

Launch Urho from your form, see Complete Sample

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.