Awesome
Xamarin.Forms for Unity
Copyright (c) 2017 Yasuhiro Taniuchi
Copyright (c) .NET Foundation Contributors
LICENSE (MIT)
Demo (WebGL Build / 2017/9/8 Version)
About
Xamarin.Forms Platform implementation for Unity Game Engine (Unity3D).
Requirements
- Unity 2018.4.1f1 (or later)
- UniRx 5.5.0 (or later)
Try the sample
- Import "Xamarin.Forms" from NuGet.
- Import "UniRx" from Unity Asset Store or GitHub.
- Open "Assets/main.unity" or "Assets/XamlPad.unity" scene file.
- Edit sample source code.
- main.unity
- Assets/Scripts/Page1.xaml.cs
- Assets/Scripts/SampleBindingContext.cs
- XamlPad.unity
- Assets/Scripts/XamlPad/XamlPadBindingContext.cs
- Assets/Scripts/XamlPad/XamlPadPage.cs
- Assets/StreamingAssets/XamlPadPage.xaml
- Run.
Getting Started
- Create New Unity Project.
- Changes "Script Runtime Version" at Player Settings to ".NET 4.6".
- Copy 'Assets/Xamarin.Forms.Unity' to Unity Project.
- Import "Xamarin.Forms".
- Download from NuGet Package (Ver.4.0.0.425677) (https://www.nuget.org/packages/Xamarin.Forms) .
- Change the extension from nupkg to zip. And unpack.
- Copy dlls from lib/netstandard2.0 to Unity Project (ex. Assets/Xamarin.Forms.Unity/Plugins) .
- Import "UniRx".
- Create App class that inherits Xamarin.Forms.Application.
- Create FormsApplicationActivity class that inherits Xamarin.Forms.Platform.Unity.UnityFormsApplicationActivity<T>. T is Application class that implemented earlier.
- Create Prefabs of UI Comoponent. (Canvas, Button, Text, InputField etc.)
- Create "UI - Canvas" on the Hierarchy of Unity scene. This Canvas is UI Root of Xamarin.Forms.
- Create "Xamarin.Forms Application Activity(User defined)" on the Hierarchy of Unity scene. This Activity must be singleton.
- Set Prefabs of UI Component and Root Canvas to Activity.
Known Issues
- XAML Loader does not work with IL2CPP Build. (maybe due to Unity (2017.1.1f1))
- NavigationPage is not implemented in the current version.
Custom Renderers is not supported in the current version.
(Please apply the design with the component of Prefab.)- Standard Renderers are under development.