private static void OnControllerChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { var instance = (UrhoViewport3D)obj; if (instance.Controller != null) { instance.Controller.Exit(); instance.Controller.Dispose(); ServiceLocator.Unregister<IUrho3DService>(); instance.Controller = null; } if (instance.ControllerType != null) { instance.UrhoHost.Child = new Panel { Dock = DockStyle.Fill }; var appOpts = new ApplicationOptions(assetsFolder: null) { ExternalWindow = instance.UrhoHost.Child.Handle, LimitFps = true, TouchEmulation = false }; instance.Controller = UrhoController.CreateInstance(instance.ControllerType, appOpts); instance.Controller.Input.MouseButtonDown += eventArgs => { instance.UrhoHost.Focus(); instance.UrhoHost.Child.Focus(); }; ServiceLocator.Register((IUrho3DService) instance.Controller); Task.Yield().GetAwaiter().OnCompleted(() => instance.Controller.Run()); } }
private async Task LaunchGame() { var mLayout = new RelativeLayout(this); surface = UrhoSurface.CreateSurface(this); mLayout.AddView(surface); SetContentView(mLayout); app = await surface.Show <Game>(new ApplicationOptions("Data")); app.Update += (obj) => { if (app.IsClosed) { Console.WriteLine("app is closed"); } if (app.IsDeleted) { Console.WriteLine("app is deleted"); } if (app.IsExiting) { Console.WriteLine("app is exiting"); } }; }
async private void UrhoPanel_FormClosing(object sender, FormClosingEventArgs e) { currentApplication?.Engine.Exit(); currentApplication = null; await semaphoreSlim.WaitAsync(); f?.Engine.Exit(); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var mLayout = new RelativeLayout(this); var surface = UrhoSurface.CreateSurface(this); mLayout.AddView(surface); SetContentView(mLayout); app = await surface.Show <BertApp>(new ApplicationOptions("Data")); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); var mLayout = new AbsoluteLayout(this); var appType = Assembly.Load("Sample").GetTypes() .Where(_ => _.IsSubclassOf(typeof(Urho.Application))) .Where(_ => !_.IsAbstract) .FirstOrDefault(); _surface = UrhoSurface.CreateSurface(this); mLayout.AddView(_surface); SetContentView(mLayout); _application = await _surface.Show(appType, new ApplicationOptions("Data")); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); var layout = new FrameLayout(this); surface = new AbsoluteUrhoSurfacePlaceholder(this) { LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) }; layout.AddView(surface); SetContentView(layout); var options = new ApplicationOptions(); app = await surface.Show <ScreenKeyboardBug>(options); }
async private void BuildScene() { currentApplication?.Engine.Exit(); currentApplication = null; await semaphoreSlim.WaitAsync(); urhoSurfacePlaceholder.Controls.Clear(); //urho will destroy previous control so we have to create a new one var urhoSurface = new Panel { Dock = DockStyle.Fill }; urhoSurfacePlaceholder.Controls.Add(urhoSurface); await Task.Delay(100);//give some time for GC to cleanup everything currentApplication = Urho.Application.CreateInstance(typeof(MySample), new ApplicationOptions("Data") { ExternalWindow = urhoSurface.Handle }); urhoSurface.Focus(); currentApplication.Run(); semaphoreSlim.Release(); }
public static void Initialize(Urho.Application app, List <DebugAction> handlers) { app.UI.Root.SetDefaultStyle(CoreAssets.UIs.DefaultStyle); buttons = new List <Button>(handlers.Count); for (int j = 0; j < handlers.Count + 1; j++) { var w = app.Graphics.Width / (handlers.Count + 1); var h = app.Graphics.Height / 25; var button = new Button(); app.UI.Root.AddChild(button); button.SetStyle("Button"); button.SetSize(w, h); button.Position = new IntVector2(w * j, 0); button.Visible = false; var label = new Text(); button.AddChild(label); label.SetStyle("Text"); label.SetFontSize((int)(label.FontSize / 1f)); label.HorizontalAlignment = HorizontalAlignment.Center; label.VerticalAlignment = VerticalAlignment.Center; int index = j; if (j == handlers.Count) { label.Value = "debug menu"; button.Visible = true; button.Pressed += args => buttons.ForEach(b => b.Visible = !b.Visible); } else { label.Value = handlers[j].Name; button.Pressed += args => handlers[index].Action(); buttons.Add(button); } } }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); var mLayout = new AbsoluteLayout(this); var appType = Assembly.Load("UrhoSharpEditor").GetTypes() .Where(_ => _.IsSubclassOf(typeof(Urho.Application))) .Where(_ => !_.IsAbstract) .FirstOrDefault(); _surface = UrhoSurface.CreateSurface(this); mLayout.AddView(_surface); SetContentView(mLayout); Android.Views.View decorView = Window.DecorView; var uiOptions = (int)decorView.SystemUiVisibility; var newUiOptions = (int)uiOptions; newUiOptions |= (int)SystemUiFlags.Fullscreen; newUiOptions |= (int)SystemUiFlags.HideNavigation; newUiOptions |= (int)SystemUiFlags.Immersive; decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; _application = await _surface.Show(appType, new ApplicationOptions("Data")); }