### Install KNIFXC .NET Tool
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/knifxc.md
Installs the KNIFXC tool globally using the .NET CLI. Ensure the .NET SDK is installed.
```bat
dotnet tool install -g dotnet-knifxc
```
--------------------------------
### Install KNI .NET Templates
Source: https://github.com/kniengine/kni/blob/main/Templates/dotnetTemplates/README.md
Use this command to install the KNI project templates for dotnet new.
```bash
dotnet new install nkast.Kni.Templates
```
--------------------------------
### Install KNI Templates using .NET CLI
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/1_setting_up_your_development_environment_windows.md
Use this command in your Command Prompt after installing the .NET 8 SDK to install the KNI templates.
```sh
dotnet new install nkast.Kni.Templates::4.2.9001-preview.7
```
--------------------------------
### Set up a Lidgren NetServer
Source: https://github.com/kniengine/kni/blob/main/ThirdParty/Lidgren.Network/Documentation/Tutorial.html
Configure and start a NetServer instance. Ensure the same application name is used on clients for communication. The server binds to a specified port and starts a network thread.
```csharp
NetPeerConfiguration config = new NetPeerConfiguration("MyExampleName");
config.Port = 14242;
NetServer server = new NetServer(config);
server.Start();
```
--------------------------------
### Install Flatpak Runtimes
Source: https://github.com/kniengine/kni/blob/main/Tools/MonoGame.Packaging.Flatpak/README.md
Installs the necessary Flatpak runtimes and adds the Flathub repository. Ensure you have Flatpak set up before running these commands.
```sh
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub org.freedesktop.Platform/x86_64/1.6
flatpak install flathub org.freedesktop.Sdk/x86_64/1.6
```
--------------------------------
### Install MGCB .NET Tool
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Installs the MGCB command-line tool globally using the .NET CLI. Ensure the .NET SDK is installed first.
```bash
dotnet tool install -g dotnet-mgcb
```
--------------------------------
### macOS Info.plist Example
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
This is an example of an Info.plist file for a macOS application bundle. It contains essential metadata for your game, such as bundle identifier, version, and application category.
```xml
CFBundleDevelopmentRegion
en
CFBundleExecutable
YourGame
CFBundleIconFile
YourGame
CFBundleIdentifier
com.your-domain.YourGame
CFBundleInfoDictionaryVersion
6.0
CFBundleName
YourGame
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
FONV
CFBundleVersion
1
LSApplicationCategoryType
public.app-category.games
LSMinimumSystemVersion
10.15
NSHumanReadableCopyright
Copyright © 2022
NSPrincipalClass
NSApplication
LSRequiresNativeExecution
LSArchitecturePriority
arm64
```
--------------------------------
### Initialize Method for Game Setup
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/3_understanding_the_code.md
Called after the constructor and before the main game loop. Use for querying services and loading non-graphic content.
```csharp
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
```
--------------------------------
### Install Wine and Dependencies
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/1_setting_up_your_development_environment_macos.md
Installs Wine, XQuartz, p7zip, and wget using Homebrew. These are required for compiling effects (shaders) on macOS.
```shell
brew install xquartz
brew install wine-stable
brew install p7zip wget
```
--------------------------------
### List Installed KNI Templates
Source: https://github.com/kniengine/kni/blob/main/Templates/dotnetTemplates/README.md
Lists all installed KNI templates.
```bash
dotnet new list kni
```
--------------------------------
### Example Response File Usage
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Demonstrates how to use a response file to configure MGCB for building textures, including setting directories, rebuilding, specifying importers and processors, and defining processor parameters.
```bash
# Directories
/outputDir:bin/foo
/intermediateDir:obj/foo
/rebuild
# Build a texture
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyEnabled=false
/build:Textures\wood.png
/build:Textures\metal.png
/build:Textures\plastic.png
```
--------------------------------
### Resx String Resource Example
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/content/localization.md
An example of a string resource within a .resx file. This defines a string with a placeholder for formatting.
```xml
Wall Style : {0}
```
--------------------------------
### Install Wine and Dependencies for Effect Compilation
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/1_setting_up_your_development_environment_ubuntu.md
Installs wine64 and necessary packages (p7zip-full, curl) required for setting up Wine on Ubuntu. This is an optional step for effect compilation.
```sh
sudo apt install wine64 p7zip-full curl
```
--------------------------------
### Game Constructor Initialization
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/3_understanding_the_code.md
Initializes starting variables, creates a GraphicsDeviceManager, and sets the root directory for content files.
```csharp
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
```
--------------------------------
### Create a KNI Project
Source: https://github.com/kniengine/kni/blob/main/Templates/dotnetTemplates/README.md
Use this command to create a new project from an installed KNI template. Replace `` with the desired template and `ProjectName` with your project's name.
```bash
dotnet new -n ProjectName
```
--------------------------------
### List Installed .NET Templates
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/2_creating_a_new_project_netcore.md
Run this command to see all available .NET templates, including MonoGame templates, and their corresponding short names (template IDs).
```bash
dotnet new -l
```
--------------------------------
### Install Homebrew Package Manager
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/1_setting_up_your_development_environment_macos.md
Installs the Homebrew package manager on macOS. This is a prerequisite for installing other development tools.
```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```
--------------------------------
### Create Wine Prefix for MonoGame Effect Compiler
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/1_setting_up_your_development_environment_ubuntu.md
Sets up a Wine prefix for the MonoGame effect compiler by downloading and executing a setup script. This is part of the optional Wine setup for effect compilation.
```sh
wget -qO- https://raw.githubusercontent.com/MonoGame/MonoGame/master/Tools/MonoGame.Effect.Compiler/mgfxc_wine_setup.sh | bash
```
--------------------------------
### Install Visual Studio Code C# Extension
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/1_setting_up_your_development_environment_ubuntu.md
Installs the C# extension for Visual Studio Code using the command line interface. This extension is required for coding and building C# projects.
```sh
code --install-extension ms-dotnettools.csharp
```
--------------------------------
### Use Response File for Options
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Specifies a text file containing MGCB command-line options. Each option should be on a new line, and lines starting with '#' are treated as comments.
```bash
/@:
```
--------------------------------
### Publish .NET Core Project for Flatpak
Source: https://github.com/kniengine/kni/blob/main/Tools/MonoGame.Packaging.Flatpak/README.md
Publishes your .NET Core project, which will generate the Flatpak installer in the output directory. This command assumes the kniengine package is correctly configured in your project.
```sh
dotnet publish -r linux-x64
```
--------------------------------
### Initialize WebGL Canvas and Game Loop
Source: https://github.com/kniengine/kni/blob/main/Templates/VisualStudio2022/ProjectTemplates/Multiplatform.NetCore/BlazorGL/wwwroot/index.html
Sets up the initial canvas size based on its container and starts the game loop by requesting the first animation frame. It also disables the context menu on right-click for a better user experience.
```javascript
function tickJS() {
window.theInstance.invokeMethod('TickDotNet');
window.requestAnimationFrame(tickJS);
}
window.initRenderJS = (instance) => {
window.theInstance = instance;
// set initial canvas size
var canvas = document.getElementById('theCanvas');
var holder = document.getElementById('canvasHolder');
canvas.width = holder.clientWidth;
canvas.height = holder.clientHeight;
// disable context menu on right click
canvas.addEventListener("contextmenu", e => e.preventDefault());
// begin game loop
window.requestAnimationFrame(tickJS);
};
```
--------------------------------
### Complete Localized SpriteFont Configuration
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/content/localization.md
A complete example of a .spritefont file configured to use the LocalizedFontProcessor and specific .resx files for localization.
```xml
Verdana
14
1
..oo.resx
..oo.de-DE.resx
```
--------------------------------
### Initialize Canvas and Game Loop
Source: https://github.com/kniengine/kni/blob/main/Templates/VisualStudio2022/ProjectTemplates/BlazorGL.NetCore/wwwroot/index.html
Sets up the canvas element for rendering, initializes its size based on its container, and starts a JavaScript-based game loop that invokes a .NET method.
```javascript
function tickJS() { window.theInstance.invokeMethod('TickDotNet'); window.requestAnimationFrame(tickJS); } window.initRenderJS = (instance) => { window.theInstance = instance; // set initial canvas size var canvas = document.getElementById('theCanvas'); var holder = document.getElementById('canvasHolder'); canvas.width = holder.clientWidth; canvas.height = holder.clientHeight; // disable context menu on right click canvas.addEventListener("contextmenu", e => e.preventDefault()); // begin game loop window.requestAnimationFrame(tickJS); };
```
--------------------------------
### Conditional Content Inclusion in Response File
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Example of a response file demonstrating conditional inclusion of build targets based on the 'BuildEffects' symbol.
```plaintext
$if BuildEffects=Yes
/importer:EffectImporter
/processor:EffectProcessor
/build:Effects\custom.fx
# all other effects here....
$endif
```
--------------------------------
### Draw Text with SpriteBatch
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/content/adding_ttf_fonts.md
Draw text to the screen using SpriteBatch. This example calculates the center of the text and positions it in the middle of the game window. Adjust the scale parameter (1.0f) to control text size.
```csharp
spriteBatch.Begin();
// Finds the center of the string in coordinates inside the text rectangle
Vector2 textMiddlePoint = font.MeasureString(text) / 2;
// Places text in center of the screen
Vector2 position = new Vector2(myGame.Window.ClientBounds.Width / 2, myGame.Window.ClientBounds.Height / 2);
spriteBatch.DrawString(font, "MonoGame Font Test", position, Color.White, 0, textMiddlePoint, 1.0f, SpriteEffects.None, 0.5f)
spriteBatch.End();
```
--------------------------------
### Build and package for Windows
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
Use this command to publish your .NET project as a self-contained application for Windows 64-bit. Ensure you are in the project directory when running this command.
```bash
dotnet publish -c Release -r win-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained
```
--------------------------------
### Build and package for Linux
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
Use this command to publish your .NET project as a self-contained application for Linux 64-bit. This command is executed from the .NET CLI within your project directory.
```bash
dotnet publish -c Release -r linux-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained
```
--------------------------------
### Comment Value Example
Source: https://github.com/kniengine/kni/blob/main/CODESTYLE.md
Comments should add value by explaining intent or logic, not just restating the code.
```csharp
// Right
// Set the initial reference count so it isn't cleaned up next frame
count = 1;
```
--------------------------------
### Build and package for macOS (x64)
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
Publish your .NET project as a self-contained application for macOS 64-bit Intel architecture. This command should be run from the .NET CLI in your project's directory.
```bash
dotnet publish -c Release -r osx-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained
```
--------------------------------
### Build and package for macOS (arm64)
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
Publish your .NET project as a self-contained application for macOS 64-bit ARM architecture. Execute this command from the .NET CLI within your project directory.
```bash
dotnet publish -c Release -r osx-arm64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained
```
--------------------------------
### Clone Kni Source Code
Source: https://github.com/kniengine/kni/blob/main/README.md
Clone the Kni repository from GitHub to get the full source code. Ensure submodules are updated.
```bash
git clone https://github.com/kniengine/kni.git
```
```bash
git submodule update --init
```
--------------------------------
### Initialize Blazor with Brotli Decompression
Source: https://github.com/kniengine/kni/blob/main/Templates/VisualStudio2022/ProjectTemplates/Multiplatform.NetCore/BlazorGL/wwwroot/index.html
Configures Blazor's startup process, enabling optional Brotli decompression for static assets when served from a web server that doesn't support content compression. This is useful for optimizing load times.
```javascript
import { BrotliDecode } from './js/decode.min.js'; window.BrotliDecode = BrotliDecode; // Set this to enable Brotli (.br) decompression on static webServers // that don't support content compression and http://. var enableBrotliDecompression = false; Blazor.start({
loadBootResource: function (type, name, defaultUri, integrity) {
if (enableBrotliDecompression === true && type !== 'dotnetjs' && location.hostname !== 'localhost') {
return (async function() {
const response = await fetch(defaultUri + '.br', {
cache: 'no-cache'
});
if (!response.ok) throw new Error(response.statusText);
const originalResponseBuffer = await response.arrayBuffer();
const originalResponseArray = new Int8Array(originalResponseBuffer);
const contentType = (type === 'dotnetwasm') ? 'application/wasm' : 'application/octet-stream';
const decompressedResponseArray = BrotliDecode(originalResponseArray);
return new Response(decompressedResponseArray, {
headers: {
'content-type': contentType
}
});
})();
}
}
});
```
--------------------------------
### Update Shader Preprocessor Defines
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_381.md
Replace MonoGame-specific preprocessor defines in your .fx files with their KNI equivalents. For example, DEBUG becomes __DEBUG__.
```hlsl
DEBUG with `__DEBUG__`
MGFX with `__KNIFX__`
HLSL and SM4 with `__DIRECTX__`
GLSL and OPENGL with `__GL__` or (`__OPENGL__` || `__GLES__`)
```
--------------------------------
### macOS Application Entry Point Script
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
This bash script serves as the entry point for your macOS application bundle. It changes the directory to Resources and then executes the appropriate game binary based on the system's architecture.
```bash
#!/bin/bash
cd "$(dirname $BASH_SOURCE)/../Resources"
if [[ $(uname -p) == 'arm' ]]; then
./../MacOS/arm64/YourGame
else
./../MacOS/amd64/YourGame
fi
```
--------------------------------
### Specify TrueType Font Name in .spritefont File
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/content/adding_ttf_fonts.md
Edit the .spritefont file to set the desired TrueType font. If the font is installed on the system, you can use its name directly.
```xml
Arial
```
--------------------------------
### Configure KNI Content Builder Platform
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_381.md
Add the KniPlatform property to your .csproj file to specify the target platform for the KNI Content Builder. Replace {Platform} with your target (e.g., Windows, DesktopGL, Android).
```xml
{Platform}
```
--------------------------------
### Update Library Project References
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_381.md
For library projects, update the .csproj file to use KNI framework references instead of MonoGame. This example shows the DesktopGL specific change.
```xml
```
```xml
```
--------------------------------
### Create MonoGame Project with .NET CLI
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/2_creating_a_new_project_netcore.md
Use this command to create a new MonoGame project with a specific template and project name. Ensure you are in your desired project directory.
```bash
dotnet new mgdesktopgl -o MyGame
```
--------------------------------
### Workflow for Implementing a Visual Test
Source: https://github.com/kniengine/kni/blob/main/Tests/README.md
This section describes a general workflow for implementing visual tests. It involves creating subclasses, composing test games, using FrameCompareComponent for frame capture and comparison, and managing reference images.
```text
1. Implement any new drawing logic needed in a new subclass of one of
the *Component base classes.
2. Compose your test Game in a new [Test] method. As this stage, you
can run the new test directly to visually verify the rendering.
3. Add a FrameCompareComponent to your test Game with at least one
IFrameComparer implementation. Use the ```FrameCompareComponent```'s
predicate to capture and compare frames.
4. Pass the FrameCompareComponent.Results to the diffing, logging and
assertion utility methods provided by ```VisualTestFixtureBase```
5. The first time a visual test is run, it will fail for lack of
reference images to compare the captured images to. However, it will
write the captured frames to bin(Configuration)CapturedFrames\{TestDir}.
6. Proof the images generated from the first run to ensure that they are
correct, then add them to the test project in
Assets\ReferenceImages\$TestDir. **Be sure to add them in the
projects for all platforms!** These files should have their build
actions set to "Compile" and "Copy if newer".
7. Rerun the visual test. The reference images should be copied into
place and the test should now pass.
8. XOR diffs between the reference images and captured frames are output
into bin(Configuration)Diffs\{TestDir} for debugging purposes.
```
--------------------------------
### Initialize Game Variables in C#
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/getting_started/5_adding_basic_code.md
Initialize ball position to the center of the screen and set the ball speed in the Initialize method.
```csharp
// TODO: Add your initialization logic here
ballPosition = new Vector2(_graphics.PreferredBackBufferWidth / 2,
_graphics.PreferredBackBufferHeight / 2);
ballSpeed = 100f;
base.Initialize();
```
--------------------------------
### Restore .NET Tools
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb_editor.md
If this is your first time running MGCB Editor via the .NET CLI, you may need to restore the necessary tools. The .NET CLI will prompt you if this is required.
```bash
dotnet tool restore
```
--------------------------------
### Set Build Configuration
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Provides an optional build configuration name, which can be used as a hint by content processors.
```bash
/config:
```
--------------------------------
### Migrate .fx Shader Defines
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_4_1.md
Update the preprocessor defines in your .fx files to use the new syntax for compatibility with the KniEngine.
```plaintext
replace DEBUG with `__DEBUG__`
```
```plaintext
replace MGFX with `__KNIFX__`
```
```plaintext
replace HLSL and SM4 with `__DIRECTX__`
```
```plaintext
replace GLSL , OPENGL and `__OPENGL__` with `__GL__` or (`__OPENGL__` || `__GLES__`)
```
--------------------------------
### Loading Typeface from Assets
Source: https://github.com/kniengine/kni/blob/main/Templates/dotnetTemplates/content/Multiplatform.NetCore.CSharp/$projectname$.Oculus.GL/Assets/AboutAssets.txt
Shows how to load a custom font file from the assets directory using Typeface.CreateFromAsset.
```csharp
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
```
--------------------------------
### Enable Trimming and AOT for DesktopGL Projects
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_3_10.md
Upgrade the TargetFramework to net8.0 and add PublishTrimmed and PublishAot properties to the .csproj file to enable trimming and Ahead-Of-Time compilation for DesktopGL builds.
```xml
True
True
```
--------------------------------
### GraphicsDeviceTestFixtureBase Methods
Source: https://github.com/kniengine/kni/blob/main/Tests/README.md
Methods for capturing and comparing rendered frames in KNI tests. PrepareFrameCapture initializes frame capture, SubmitFrame stores frame data, and CheckFrames compares captured frames against references.
```csharp
PrepareFrameCapture
SubmitFrame
CheckFrames
```
--------------------------------
### Respond to Discovery Request (Server)
Source: https://github.com/kniengine/kni/blob/main/ThirdParty/Lidgren.Network/Documentation/Discovery.html
Handle incoming DiscoveryRequest messages on the server. Create a response message, write server information, and send it back to the client's endpoint.
```csharp
while ((inc = Server.ReadMessage()) != null)
{
switch (inc.MessageType)
{
case NetIncomingMessageType.DiscoveryRequest:
// Create a response and write some example data to it
NetOutgoingMessage response = Server.CreateMessage();
response.Write("My server name");
// Send the response to the sender of the request
Server.SendDiscoveryResponse(response, inc.SenderEndpoint);
break;
```
--------------------------------
### macOS Application Bundle Structure
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/packaging_games.md
This illustrates the standard directory structure for a macOS application bundle. Place your game's executable and content within the appropriate subdirectories.
```text
YourGame.app (this is your root folder)
- Contents
- Resources
- Content (this is where all your content and XNB's should go)
- YourGame.icns (this is your app icon, in ICNS format)
- MacOS
- amd64 (this is where your game executable for amd64 belongs, place files from the osx-x64/publish directory here)
- amd64 (this is where your game executable for arm64 belongs, place files from the osx-arm64/publish directory here)
- YourGame (the entry point script of your app, see bellow for contents)
- Info.plist (the metadata of your app, see bellow for contents)
```
--------------------------------
### Include Content with Wildcards in .csproj
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/content/using_mgcb_editor.md
Use this XML snippet in your .csproj file to automatically include all .xnb files within a Content folder and its subdirectories into the build output. Ensure the Content folder is at the root of your game project.
```xml
PreserveNewest
```
--------------------------------
### Launch Debugger
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Enables attaching a debugger to the MGCB process before content building begins, useful for debugging the build pipeline itself.
```bash
/launchdebugger
```
--------------------------------
### Initialize Canvas and Game Loop
Source: https://github.com/kniengine/kni/blob/main/Templates/dotnetTemplates/content/Multiplatform.NetCore.CSharp/$projectname$.Blazor.GL/wwwroot/index.html
Sets up the initial canvas size based on its container and begins the animation frame loop for rendering. It also disables the context menu on right-click and prevents default scrolling behavior for specific keys and the mouse wheel.
```javascript
function tickJS() { window.theInstance.invokeMethod('TickDotNet'); window.requestAnimationFrame(tickJS); } window.initRenderJS = (instance) => { window.theInstance = instance; // set initial canvas size var canvas = document.getElementById('theCanvas'); var holder = document.getElementById('canvasHolder'); canvas.width = holder.clientWidth; canvas.height = holder.clientHeight; // disable context menu on right click canvas.addEventListener("contextmenu", e => e.preventDefault()); // begin game loop window.requestAnimationFrame(tickJS); }; window.addEventListener("keydown", function(event) { // Prevent Arrows Keys and Spacebar scrolling the outer page // when running inside an iframe. e.g: itch.io embedding. if (\\\[32, 37, 38, 39, 40\\].indexOf(event.keyCode) > -1) event.preventDefault(); }); window.addEventListener("wheel", function(event) { // Prevent Mousewheel scrolling the outer page // when running inside an iframe. e.g: itch.io embedding. event.preventDefault(); }, { passive: false });
```
--------------------------------
### Accessing Raw Assets
Source: https://github.com/kniengine/kni/blob/main/Templates/dotnetTemplates/content/Multiplatform.NetCore.CSharp/$projectname$.Oculus.GL/Assets/AboutAssets.txt
Demonstrates how to open and read a raw asset file using Android's AssetManager in a C# Activity.
```csharp
public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
InputStream input = Assets.Open ("my_asset.txt");
}
}
```
--------------------------------
### Migrate BlazorGL Project References
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_3_10.md
Update .csproj file to conditionally include package references for .NET 6 and .NET 8 target frameworks. This ensures compatibility with newer .NET versions.
```xml
```
```xml
```
--------------------------------
### Update OculusVR .csproj
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_3_14.md
Replace the OculusVR package reference in the .csproj file with the new version.
```xml
```
```xml
```
--------------------------------
### Set Target Platform
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/tools/mgcb.md
Specifies the target platform for the content build. Must be a valid `TargetPlatform` enum member (e.g., Windows, iOS, Android, DesktopGL, WebGL). Defaults to Windows.
```bash
/platform:
```
--------------------------------
### Register XRFactory in OculusVR Program.cs
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_3_14.md
Before creating the Game instance in Program.cs, register the XRFactory for OculusVR support.
```csharp
Microsoft.Xna.Platform.XR.XRFactory.RegisterXRFactory(new Microsoft.Xna.Platform.XR.LibOVR.ConcreteXRFactory());
using (var game = new $ext_safeprojectname$Game())
game.Run();
```
--------------------------------
### Update Framework Package References
Source: https://github.com/kniengine/kni/blob/main/Documentation/articles/migrate_3_10.md
Replace existing nkast.Xna.Framework and MonoGame.Framework package references with the new versions for 3.11. Ensure all necessary framework components are included.
```xml
```
```xml
```
--------------------------------
### Enable Discovery Response Messages
Source: https://github.com/kniengine/kni/blob/main/ThirdParty/Lidgren.Network/Documentation/Discovery.html
Enable the client to receive DiscoveryResponse messages. This is a prerequisite for discovering servers.
```csharp
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
```