Coherent UI for .NET  2.5.3
A modern user interface library for games
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
.NET Sample guides

Here you can find walkthroughs for each .NET Coherent UI sample. Make sure you read the prerequisites below first.

Before you start

The .NET variant of Coherent UI depends on the native Coherent UI DLL, CoherentUI.dll. You need both CoherentUINET.dll and CoherentUI.dll to deploy your application.
For Windows operating systems you'd place them either in the application directory or a system directory that the OS tries to load dynamic libraries from (such as system32), but the former is recommended.
For Linux, CoherentUINET.dll and libCoherentUI.so must reside in a directory that is present in your LD_LIBRARY_PATH. The Linux samples compile and run with MonoDevelop 3.

Note that the native dll is NOT the same as the one distributed with the C++ variant of Coherent UI, i.e. they are not interchangeable.

ViewContext initialization

First, a view context factory should be created via the method CoherentUI.InitializeCoherentUI. Then the view context is created by calling the CoherentUI.CreateViewContext method. This class, as well as all the other Coherent UI .NET classes reside in the Coherent.UI namespace (or a sub-namespace).

Garbage collection and listener classes

Warning
It is very important that you save the references to the listener instances you create so they are valid throughout the lifetime of the view context(or the corresponding view, for ViewListener). This is required because no reference is made internally and if you don't save at least one yourself, the garbage collector will dispose the object. Later, when a callback is received, a method on that object instance is called, and if the object is collected, an exception will be thrown.

Events

Instead of overriding virtual methods (as in the Coherent UI C++ version), the Coherent UI .NET provides events as a callback mechanism. The events are used for almost all callbacks, except virtual methods that return a value and are meant to be overridden (and also avoid deriving a return value from multiple subscribers), e.g. CreateSurface.

You can still override the virtual methods, but in that case the event will not be fired, because that happens in the default implementation. If you want to override the method and still fire the event, you must call base.OnXXX(...) in the body of the overridden method.

The License.cs file

The samples use the variable Coherent.UI.License.COHERENT_KEY to initialize CoherentUI. To compile them successfully, you need to make a file named License.cs in CoherentInstallDir/Samples/C# (where CoherentInstallDir refers to the directory where you installed Coherent UI). The file should have the following contents:

namespace Coherent.UI
{
static class License
{
public const string COHERENT_KEY = <Insert your license key here>;
}
}

Now you are ready to explore the .NET samples!