Hello,
Welcome to our Microsoft Q&A platform!
If you use urhosharp to load 3D models, you do not need to create a custom view,Install UrhoSharp.Forms in your platform and PCL projects. Put urhosharp to <StackLayout>
and use <ScrollView>
to contains that like following code.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:urho="clr-namespace:Urho.Forms;assembly=UrhoSharp.Forms"
x:Class="Urho3DDemo.MainPage">
<StackLayout>
<ScrollView>
<StackLayout>
<StackLayout>
<urho:UrhoSurface x:Name="HelloWorldUrhoSurface" HorizontalOptions="FillAndExpand" HeightRequest="300"/>
</StackLayout>
<StackLayout>
<urho:UrhoSurface x:Name="HelloWorldUrhoSurface2" HorizontalOptions="FillAndExpand" HeightRequest="300"/>
</StackLayout>
<StackLayout>
<urho:UrhoSurface x:Name="HelloWorldUrhoSurface3" HorizontalOptions="FillAndExpand" HeightRequest="300"/>
</StackLayout>
</StackLayout>
</ScrollView>
</StackLayout>
</ContentPage>
Here is layout background code.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
protected override async void OnAppearing()
{
base.OnAppearing();
await HelloWorldUrhoSurface.Show<HelloWorld>(new Urho.ApplicationOptions(assetsFolder: null) { Orientation = ApplicationOptions.OrientationType.LandscapeAndPortrait });
await HelloWorldUrhoSurface2.Show<HelloWorld>(new Urho.ApplicationOptions(assetsFolder: null) { Orientation = ApplicationOptions.OrientationType.LandscapeAndPortrait });
await HelloWorldUrhoSurface3.Show<HelloWorld>(new Urho.ApplicationOptions(assetsFolder: null) { Orientation = ApplicationOptions.OrientationType.LandscapeAndPortrait });
}
}
Here is HelloWorld.cs
.
using Urho;
using Urho.Actions;
using Urho.Gui;
namespace Urho3DDemo
{
public class HelloWorld : Application
{
//public HelloWorld() { }
public HelloWorld(ApplicationOptions options) : base(options) { }
protected override async void Start()
{
base.Start();
CreateText();
}
private void CreateText()
{
// Create Text Element
var text = new Text()
{
Value = "Hello World!",
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
text.SetColor(Color.Cyan);
text.SetFont(font: ResourceCache.GetFont("Fonts/Anonymous Pro.ttf"), size: 30);
// Add to UI Root
UI.Root.AddChild(text);
}
}
}
Here is running screenshot.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.