Urho.Application Class

Base class for creating applications which initialize the Urho3D engine and run a main loop until exited.

See Also: Application

Syntax

[Preserve(AllMembers=true)]
public class Application : UrhoObject

Remarks

This is the base class that your application should subclass and provide at implementations for the Application.Setup and Application.Start methods.  You can use await asynchronous methods from the Application.Start methods.

Access to various subsystems in Urho is available through the various properties in this class:

An application is tied to a Context which should be passed on the initial constructor.

This shows a minimal application:

C# Example

public class HelloWorld : Application
{
    public HelloWorld(Context c) : base(c) { }

    public override void Start()
    {
        var cache = ResourceCache;
        var helloText = new Text(Context) {
            Value = "Hello World from UrhoSharp",
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Center
        };
        helloText.SetColor (new Color(0f, 1f, 0f));
        helloText.SetFont (font: cache.GetFont("Fonts/Anonymous Pro.ttf"), size: 30);
        UI.Root.AddChild (helloText);

        Graphics.SetWindowIcon(cache.GetImage("Textures/UrhoIcon.png"));
        Graphics.WindowTitle = "UrhoSharp Sample";

        // Subscribe to Esc key:
        SubscribeToKeyDown(args => { if (args.Key == Key.Esc) Engine.Exit(); });
    }
}

Requirements

Namespace: Urho
Assembly: Urho (in Urho.dll)
Assembly Versions: 1.0.0.0

The members of Urho.Application are listed below.

See Also: UrhoObject

Public Constructors

Constructs a new instance of Urho.Application, given a raw pointer to an unmanaged object

Protected Constructors

Empty constructor, chain to this constructor when you provide your own constructor that sets the handle field.

Public Fields

const
PixelSizeSingle (0.01).

Public Properties

[read-only]
AudioAudio. Returns the Audio subsystem.
[read-only]
ConsoleUrhoConsole. Returns the Console subsystem
[read-only]
static
CurrentApplication. Last created application.
[read-only]
static
CurrentContextContext.
[read-only]
EngineEngine. Returns the application’s engine.
[read-only]
FileSystemFileSystem. Returns the FileSystem subsystem.
[read-only]
GraphicsGraphics. Returns the Graphics subsystem.
[read-only]
HandleIntPtr.
[read-only]
static
HasCurrentBoolean. Determines if the Current property has been set.
[read-only]
InputInput. Returns the Input subsystem.
[read-only]
IsClosedBoolean. Determines if the application has been closed, and we are shutting down.
[read-only]
IsExitingBoolean.
[read-only]
LogLog. Returns the Log subsystem.
[read-only]
NetworkNetwork. Returns the Network subsystem.
[read-only]
OptionsApplicationOptions. The application options in use
[read-only]
static
PlatformPlatforms. Simple way of obtaining the platform on which the program is running from cross platform code.
[read-only]
ProfilerProfiler. Returns the Profiler subsystem.
[read-only]
RendererRenderer. Returns the Renderer subsystem.
[read-only]
ResourceCacheResourceCache. Returns the ResourceCache subsystem.
[read-only]
TimeTime. Returns the Time subsystem.
[read-only]
override
TypeStringHash. Urho's type system type.
[read-only]
override
TypeNameString. Urho's low-level type name.
[read-only]
static
TypeNameStaticString. Urho's low-level type name, accessible as a static method.
[read-only]
static
TypeStaticStringHash. Urho's low-level type, accessible as a static method.
[read-only]
UIUI. Returns the UI subsystem.
[read-only]
UrhoSurfaceIUrhoSurface.
[read-only]
WorkQueueWorkQueue. Returns the WorkQueue subsystem.

Protected Properties

[read-only]
override
AllowNativeDeleteBoolean.

Public Methods

static
CreateInstance(Type, ApplicationOptions) : Application
static
CreateInstance<T>(ApplicationOptions) : T
ErrorExit(String)
Show an error message (last log message if empty), terminate the main loop, and set failure exit code.
Exit() : Task
static
InvokeOnMain(Action)
Invoke actions in the Main Thread (the next Update call)
static
InvokeOnMainAsync(Action) : System.Threading.Tasks.Task<bool>
Run() : Int32
Initialize the engine and run the main loop, then return the application exit code. Catch out-of-memory exceptions while running.
static
ToMainThreadAsync() : System.Runtime.CompilerServices.ConfiguredTaskAwaitable<bool>

Protected Methods

OnUpdate(Single)
This method is invoked on every application update.
Setup()
Method invoked to setup your application. 
Start()
Method invoked to start your application, this is where you would typically create your scene.
Stop()
Method invoked to terminate your application.

Public Events

static
StartedEvent raised when your application has started.
static
StopedEvent raised when your application has stopped.
static
UnhandledException
UpdateFrame update event