### Start Development Server Source: https://github.com/stride3d/stride-docs/blob/master/en/contributors/website/installation.md Start the Eleventy development server to preview the website locally. The site will automatically refresh on file changes. ```bash npm start ``` ```bash npx @11ty/eleventy --serve ``` -------------------------------- ### Example Video Script Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/video/set-up-a-video.md A basic C# script that plays a video component when the game starts. Ensure the script is attached to an entity with a VideoComponent. ```csharp { public class VideoScript : StartupScript { // Game Studio displays the public member fields and properties you declare in this script public override void Start() { // Initialization of the script. Entity.Get().Instance.Play(); } } } ``` -------------------------------- ### Example .sdpkg File Configuration Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/files-and-folders/project-packages/package-properties.md This example demonstrates the structure of a .sdpkg file, including definitions for package metadata, asset folders, and resource folders. ```yaml !Package SerializedVersion: {Assets: 3.1.0.0} Meta: Name: MyGame Version: 1.0.0 Authors: [] Owners: [] Dependencies: null AssetFolders: - Path: !dir Assets - Path: !dir Effects ResourceFolders: - !dir Resources OutputGroupDirectories: {} ExplicitFolders: [] Bundles: [] TemplateFolders: [] RootAssets: [] ``` -------------------------------- ### Install Stride Project Templates Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/get-started/create-a-project.md Install the necessary Stride project templates from NuGet before creating a project via the command line. ```bash dotnet new install Stride.Templates.Games ``` -------------------------------- ### Example Script: Texture Loading Log Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/troubleshooting/logging.md This script demonstrates logging the status of texture loading. It logs a debug message when starting, and an error or debug message upon completion based on whether the texture was loaded successfully. ```csharp using System.Linq; using System.Text; using System.Threading.Tasks; using Stride.Core.Diagnostics; using Stride.Core.Mathematics; using Stride.Input; using Stride.Engine; using Stride.Graphics; namespace MyGame { public class Script : SyncScript { public Texture myTexture; public override void Start() { // Initialization of the script. Log.ActivateLog(LogMessageType.Debug); Log.Debug("Start loading MyTexture"); myTexture = Content.Load("MyTexture"); if (myTexture == null) { Log.Error("MyTexture not loaded"); } else { Log.Debug("MyTexture loaded successfully"); } } } } ``` -------------------------------- ### Example of Complete Package Definition with Custom Template Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/custom-assets.md This is a full example of a *.sdpkg file that includes a custom template folder. Verify that 'TemplateFolders' is correctly integrated. ```yaml !Package SerializedVersion: {Assets: 3.1.0.0} Meta: Name: MyGame21 Version: 1.0.0 Authors: [] Owners: [] Dependencies: null AssetFolders: - Path: !dir Assets - Path: !dir Effects ResourceFolders: - !dir Resources OutputGroupDirectories: {} ExplicitFolders: [] Bundles: [] TemplateFolders: - Path: !dir Templates Group: Assets Files: - !file Templates/YOUR_TEMPLATE.sdtpl RootAssets: [] ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/stride3d/stride-docs/blob/master/en/contributors/website/installation.md Install all necessary dependencies for the Stride website project using npm. ```bash npm install ``` -------------------------------- ### Basic StartupScript Implementation Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/example-snippets.md Implement the Start and Cancel methods for scripts that run once at startup. ```csharp public class BasicMethods : StartupScript { public override void Start() { } public override void Cancel() { } } ``` -------------------------------- ### Install SDL2 Package (Arch) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the SDL2 library package for window creation and event handling on Arch Linux. ```bash sudo pacman -S sdl2 ``` -------------------------------- ### Docfx Build Menu Example Source: https://github.com/stride3d/stride-docs/wiki/Installation An example of the interactive menu presented when running the documentation build script. Users select options to build documentation in different languages or run the local website. ```text Please select an option: [en] Build English documentation [jp] Build Japanese documentation [all] Build documentation in all available languages [r] Run local website [c] Cancel Your choice: ``` -------------------------------- ### Sample Sync Script Example Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/create-a-script.md A synchronous script example that updates every frame. This script must derive from SyncScript and implement the Update method. ```csharp using System; using System.Text; using System.Threading.Tasks; using Stride.Core.Mathematics; using Stride.Input; using Stride.Engine; namespace MyGame { public class SampleSyncScript : SyncScript { public override void Update() { if (Game.IsRunning) { // Do something every frame } } } } ``` -------------------------------- ### Geometry Shader Example Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/graphics/effects-and-shaders/shading-language/shader-stages.md This example demonstrates a geometry shader. It takes a triangle as input and outputs to a PointStream. Remember to fill the streams object and always append to the pointStream. ```cs [maxvertexcount(1)] void GSMain(triangle Input input[3], inout PointStream pointStream) { ... // fill the streams object streams = input[0]; ... // always append streams pointStream.Append(streams); ... ``` -------------------------------- ### Basic SyncScript Implementation Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/example-snippets.md Implement the Start, Cancel, and Update methods for synchronous script execution. ```csharp public class BasicMethods : SyncScript { public override void Start() { } public override void Cancel() { } public override void Update() { } } ``` -------------------------------- ### Create a SpriteBatch Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/graphics/low-level-api/spritebatch.md Instantiate a SpriteBatch with the GraphicsDevice. This is the basic setup for sprite rendering. ```csharp var spriteBatch = new SpriteBatch(GraphicsDevice); ``` -------------------------------- ### Base Collection Yaml Example Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/engine/asset-introspection.md Illustrates a base collection in YAML format with item IDs. ```yaml Strings: 309e0b5643c5a94caa799a5ea1480617: Hello e09ec493d05e0446b75358f0e1c0fbdd: World 9550f04dcee1d24fa8a30e41eea71a94: Example 1da8adce3f0ce9449a9ed0e48cd32f20: BaseClass ``` -------------------------------- ### Basic Startup Script Implementation Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/types-of-script/startup-script.md Implement the `Start()` method for initialization logic when the script is loaded and `Cancel()` for cleanup when it's unloaded. These methods are only called during runtime. ```csharp public class Example : StartupScript { public override void Start() { // Do stuff for when the script is loaded } public override void Cancel() { // Do stuff for when the script is unloaded } } ``` -------------------------------- ### Install OpenAL Package (Arch) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the OpenAL library package for sound and music playback on Arch Linux. ```bash sudo pacman -S openal ``` -------------------------------- ### Install FreeType Package (Arch) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the FreeType library package required for font rendering on Arch Linux. ```bash sudo pacman -S freetype2 ``` -------------------------------- ### Install Specific Docfx Version Source: https://github.com/stride3d/stride-docs/blob/master/en/contributors/documentation/installation.md Installs a specific version of the Docfx CLI. Useful for downgrading or ensuring compatibility. ```bash dotnet tool update -g docfx --version 2.74.1 ``` -------------------------------- ### Basic StartupScript in Stride Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/stride-for-godot-developers/index.md Illustrates the basic structure of a StartupScript in Stride, including the Start() method for initialization and Cancel() for cleanup. This is analogous to Godot's _Ready() and _Exit() methods. ```csharp public class BasicMethods : StartupScript { // Public member fields and properties that will be visible in Game Studio public override void Start() { // Initialization code for the script } public override void Cancel() { // Cleanup code for the script } } ``` -------------------------------- ### Install FreeImage Package (Arch) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the FreeImage library package for loading and saving image formats on Arch Linux. ```bash sudo pacman -S freeimage ``` -------------------------------- ### Sync Script Initialization Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/types-of-script/sync-script.md Demonstrates initializing services in the Start method for use in the Update method. This pattern ensures services are ready before per-frame logic executes. ```csharp public class Example : SyncScript { private MyExampleService service; // Initialize our script public class Start() // Note: This should be 'public override void Start()' { service = Services.GetService(); } // Perform logic every frame public class Update() // Note: This should be 'public override void Update()' { service.DoSomething(); } } ``` -------------------------------- ### Initialize Window Properties with Startup Script Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/graphics/window-configuration.md Use a Startup Script in the root scene to set initial window properties before the game window is opened. This is the recommended approach for configuring window settings programmatically. ```csharp using Stride.Engine; namespace MyGame { public class WindowSetupScript : StartupScript { public override void Start() { // Set window properties here // Example Game.Window.IsBorderLess = true; } } } ``` -------------------------------- ### Install OpenAL Development Package (Fedora) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the OpenAL library development package for sound and music playback on Fedora systems. ```bash sudo dnf install openal-soft-devel ``` -------------------------------- ### Install FreeType Development Package (Fedora) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the FreeType library development package required for font rendering on Fedora systems. ```bash sudo dnf install freetype-devel ``` -------------------------------- ### Create Project with Specific Parameters (PowerShell) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/get-started/create-a-project.md Example command to create a Stride project named 'ProjectX', enabling HDR, and targeting Windows and Linux platforms using PowerShell. ```powershell dotnet new stride-game -n ProjectX --HDR true --platform windows`|linux ``` -------------------------------- ### Create and Run Game Instance Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/files-and-folders/project-packages/index.md This C# code demonstrates the basic structure of a Stride game's entry point, where a game instance is created and then run. This is typically found in the NameOfGameApp.cs file for most platforms. ```csharp using Stride.Engine; using var game = new Game(); game.Run(); ``` -------------------------------- ### Creating a Startup Script Component Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/get-started/key-concepts.md Demonstrates how to define a custom component by inheriting from StartupScript. This script runs once when added to an entity. ```csharp using Stride.Engine; namespace MyGame; public class MyComponent : StartupScript { public override void Start() { // Write your code here } } ``` -------------------------------- ### STRDIAG003 Example Source: https://github.com/stride3d/stride-docs/blob/master/en/diagnostics/STRDIAG003.md This example demonstrates properties with private, protected, and private protected visibility, each marked with [DataMember], which will generate the STRDIAG003 warning. ```csharp using Stride.Core; public class STRDIAG003 { [DataMember] private int Value { get; set; } [DataMember] protected string Value; [DataMember] private protected string Value; } ``` -------------------------------- ### Install FreeImage Development Package (Fedora) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the FreeImage library development package for loading and saving image formats on Fedora systems. ```bash sudo dnf install freeimage-devel ``` -------------------------------- ### Open File with VirtualFileSystem Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/engine/file-system.md Demonstrates opening a file using VirtualFileSystem.OpenStream with a full path and alternatively accessing the same file through its specific mount point. ```cs // Open a file through VirtualFileSystem var gamesave1 = VirtualFileSystem.OpenStream("/roaming/gamesave001.dat", VirtualFileMode.Open, VirtualFileAccess.Read); // Alternatively, directly access the same file through its file system provider (mount point) var gamesave2 = VirtualFileSystem.ApplicationRoaming.OpenStream("gamesave001.dat", VirtualFileMode.Open, VirtualFileAccess.Read); ``` -------------------------------- ### Install SDL2 Development Package (Fedora) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the SDL2 library development package for window creation and event handling on Fedora systems. ```bash sudo dnf install SDL2-devel ``` -------------------------------- ### Load OBJ File at Runtime Source: https://github.com/stride3d/stride-docs/blob/master/en/community-resources/tools-and-importers.md Demonstrates how to load a Wavefront OBJ file from the filesystem during runtime using C# code. ```csharp using Stride.Core.IO; using Stride.Core.Mathematics; using Stride.Engine; using Stride.Rendering; using Stride.Rendering.Compositing; using Stride.Assets.Models; public class LoadObj : SyncScript { public override void Start() { // Load the OBJ file var objMesh = Content.Load("LoadObjTest/obj/test.obj"); // Create a new entity for the loaded model var entity = new Entity("Loaded OBJ Model"); // Add a model component to the entity var modelComponent = new ModelComponent(); modelComponent.Model = objMesh.ToModel(); entity.Add(modelComponent); // Add the entity to the scene Scene.Entities.Add(entity); } } ``` -------------------------------- ### Install OpenAL Development Package (Debian/Ubuntu) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the OpenAL library development package for sound and music playback on Debian and Ubuntu systems. ```bash sudo apt install libopenal-dev ``` -------------------------------- ### Startup Script Initialization in C# Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/scripts/types-of-script/index.md Use startup scripts for initializing game elements when they are added or destroyed when the scene unloads. Override the Start method for initialization logic. ```csharp public class Example : StartupScript { public override void Start() { // Do some stuff during initialization } } ``` -------------------------------- ### Accelerometer Usage Example Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/input/sensors.md Demonstrates how to check for accelerometer availability, enable it, read acceleration data, and disable it after use. Ensure to check for sensor availability before activation. ```cs public class SensorScript : AsyncScript { public override async Task Execute() { // Check availability of the sensor if(Input.Accelerometer != null) return; // Activate the sensor Input.Accelerometer.IsEnabled = true; while (Game.IsRunning) { // read current acceleration var accel = Input.Accelerometer.Acceleration; // perform require works... await Script.NextFrame(); } // Disable the sensor after use Input.Accelerometer.IsEnabled = false; } } ``` -------------------------------- ### Install FreeType Development Package (Debian/Ubuntu) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the FreeType library development package required for font rendering on Debian and Ubuntu systems. ```bash sudo apt install libfreetype6-dev ``` -------------------------------- ### Create Project with Specific Parameters (Bash) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/get-started/create-a-project.md Example command to create a Stride project named 'ProjectX', enabling HDR, and targeting Windows and Linux platforms using Bash. Note the escaped pipe character. ```bash dotnet new stride-game -n ProjectX --HDR true --platform windows\|linux ``` -------------------------------- ### Tessellation Domain Shader Example Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/graphics/effects-and-shaders/shading-language/shader-stages.md Example of a domain shader (DSMain) which performs tessellation. It takes tessellated input and constants, and outputs to 'Output'. ```cs [domain("tri")] void DSMain(const OutputPatch input, out Output output, in Constants constants, float3 f3BarycentricCoords : SV_DomainLocation) { ... output = streams; ... ``` -------------------------------- ### Install FreeImage Development Package (Debian/Ubuntu) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the FreeImage library development package for loading and saving image formats on Debian and Ubuntu systems. ```bash sudo apt install libfreeimage-dev ``` -------------------------------- ### Install SDL2 Development Package (Debian/Ubuntu) Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/platforms/linux/setup-and-requirements.md Installs the SDL2 library development package for window creation and event handling on Debian and Ubuntu systems. ```bash sudo apt install libsdl2-dev ``` -------------------------------- ### Create .sdpkg file template Source: https://github.com/stride3d/stride-docs/blob/master/en/manual/files-and-folders/project-packages/create-a-package.md Use this template to create a .sdpkg file for a new package. Remember to replace 'MyGame.MyLibrary' with your package's name. ```yaml !Package SerializedVersion: {Assets: 3.1.0.0} Meta: Name: MyGame.MyLibrary Version: 1.0.0 Authors: [] Owners: [] Dependencies: null AssetFolders: - Path: !dir Assets - Path: !dir Effects ResourceFolders: - !dir Resources OutputGroupDirectories: {} ExplicitFolders: [] Bundles: [] TemplateFolders: [] RootAssets: [] ```