-
Notifications
You must be signed in to change notification settings - Fork 4
/
UnityPlatform.cs
60 lines (53 loc) · 2.01 KB
/
UnityPlatform.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Platform;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Platform;
using Avalonia.Rendering;
using Unilonia.Input;
namespace Avalonia
{
public static class UnityApplicationExtensions
{
public static T UseUnity<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.UseWindowingSubsystem(Unilonia.UnityPlatform.Initialize, "Unity");
return builder;
}
}
}
namespace Unilonia
{
internal class UnityPlatform : IPlatformSettings, IWindowingPlatform
{
private static readonly UnityPlatform s_instance = new UnityPlatform();
public Size DoubleClickSize => new Size(4, 4);
public TimeSpan DoubleClickTime => TimeSpan.FromSeconds(0.2);
public static void Initialize()
{
var threading = new UniloniaPlatformThreadingInterface();
AvaloniaLocator.CurrentMutable
.Bind<IClipboard>().ToSingleton<ClipboardImpl>()
.Bind<IStandardCursorFactory>().ToSingleton<CursorFactory>()
.Bind<IKeyboardDevice>().ToSingleton<KeyboardDevice>()
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialogImpl>()
.Bind<IPlatformSettings>().ToConstant(s_instance)
.Bind<IWindowingPlatform>().ToConstant(s_instance)
.Bind<IPlatformIconLoader>().ToSingleton<PlatformIconLoader>()
.Bind<IPlatformThreadingInterface>().ToConstant(threading)
.Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>()
.Bind<IRenderLoop>().ToConstant(new RenderLoop())
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60));
}
public IWindowImpl CreateEmbeddableWindow()
{
throw new NotSupportedException();
}
public IWindowImpl CreateWindow()
{
throw new NotSupportedException();
}
}
}