Skip to content

Commit

Permalink
Merge pull request #354 from stride3d/master
Browse files Browse the repository at this point in the history
Deploy latest documentation updates to staging
  • Loading branch information
VaclavElias authored Dec 5, 2024
2 parents 7cd708e + 1d4209c commit a2ef883
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 60 deletions.
38 changes: 38 additions & 0 deletions en/manual/extensibility/csharp-libraries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# C# Libraries

<span class="badge text-bg-primary">Advanced</span>
<span class="badge text-bg-success">Programmer</span>

If you want to share code between multiple projects or create reusable components, you can create a C# library and reference it in your Stride project.

If your library uses the @Stride.Core.DataContractAttribute and you want to reference it through a **NuGet** package, there are additional steps required to make it compatible with Stride.

## Adding a Module Initializer

First, add a module initializer to your library. This ensures your library is properly registered with Stride's serialization system.

Example `Module.cs`:

```csharp
using Stride.Core.Reflection;
using System.Reflection;

namespace MyProjectName;

internal class Module
{
[ModuleInitializer]
public static void Initialize()
{
AssemblyRegistry.Register(typeof(Module).GetTypeInfo().Assembly, AssemblyCommonCategories.Assets);
}
}
```

## Updating to the Latest Stride NuGet Packages

If your library references any Stride NuGet packages, you must recompile it with the latest version of those packages. This ensures compatibility with the current Stride ecosystem.

## About the Module Initializer Attribute

The `ModuleInitializer` attribute is now generated using a Roslyn source generator. This means the file `sources/core/Stride.Core.CompilerServices/Generators/ModuleInitializerGenerator.cs` must run during your code's compilation. Otherwise, the module initializer and potentially other source generators added in the future will not function correctly.
7 changes: 7 additions & 0 deletions en/manual/extensibility/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Extensibility

## Introduction

Stride game project is a regular .NET project, and as such, it can be extended by a regular C# library. This is a great way to share code between multiple projects, or to create reusable components.

Read more about this subject in [C# Libraries](extensibility/csharp-libraries.md).
16 changes: 8 additions & 8 deletions en/manual/particles/initializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Initializers** control the states of particles such as position, velocity, size, and so on when the particles are first spawned. They have no effect on particles spawned on previous frames.

> [!Note]
Some [updaters](updaters.md) act change the particle's value at the *end* of the frame. They effectively overwrite any initial values set by a similar initializer. Such is the case with all animations. They operate on the particle's lifetime and a color animation updater will overwrite any initial values from a color initializer.
> Some [updaters](updaters.md) act change the particle's value at the *end* of the frame. They effectively overwrite any initial values set by a similar initializer. Such is the case with all animations. They operate on the particle's lifetime and a color animation updater will overwrite any initial values from a color initializer.
Similarly, initializers which operate on the same field are exclusive and only the bottom one will have any effect, since they are executed in order. For example if you assign two color initializer, only the second one will have any effect.]

Expand Down Expand Up @@ -39,7 +39,7 @@ Particles are spawned in an axis-aligned bounding box, defined by its left lower

| Property | Description
|-----------------------------|-------------
| Seed offset | Used for random numbers. Set it to the same value to force the position to be coupled with other other particle fields which have three properties (X, Y, Z), eg velocity. Make them different to force the position to be unique and independent from other fields
| Seed offset | Used for random numbers. Set it to the same value to force the position to be coupled with other particle fields which have three properties (X, Y, Z), eg velocity. Make them different to force the position to be unique and independent from other fields
| Position min | Left lower back corner for the box
| Position max | Right upper front corner for the box

Expand All @@ -55,7 +55,7 @@ Particles spawn with initial velocity which ranges between the defined values. T

| Property | Description
|-----------------------------|-------------
| Seed offset | This is used for random numbers. Set it to the same value to force the velocity to be coupled with other other particle fields which have 3 properties (x, Y, Z), like position for example. Make them different to force the velocity to be unique and independent from other fields.
| Seed offset | This is used for random numbers. Set it to the same value to force the velocity to be coupled with other particle fields which have 3 properties (X, Y, Z), like position for example. Make them different to force the velocity to be unique and independent from other fields.
| Velocity min | Left lower back corner for the box
| Velocity max | Right upper front corner for the box

Expand Down Expand Up @@ -111,7 +111,7 @@ This initializer creates the **Direction** field in the particle properties and

| Property | Description
|-----------------------------|-------------
| Seed offset | This is used for random numbers. Set it to the same value to force the direction to be coupled with other other particle fields which have 3 properties (x, Y, Z), like position for example. Make them different to force the velocity to be unique and independent from other fields.
| Seed offset | This is used for random numbers. Set it to the same value to force the direction to be coupled with other particle fields which have 3 properties (X, Y, Z), like position for example. Make them different to force the velocity to be unique and independent from other fields.
| Direction min | Left lower back corner for the box
| Direction max | Right upper front corner for the box

Expand All @@ -127,23 +127,23 @@ The arc position initializer positions the particles in an arc (or a straight li

| Property | Description
|-----------------------------|------------
| Seed offset | This is used for random numbers. Set it to the same value to force the position to be coupled with other other particle fields which have 3 properties (X, Y, Z), like velocity for example. Make them different to force the position to be unique and independent from other fields.
| Seed offset | This is used for random numbers. Set it to the same value to force the position to be coupled with other particle fields which have 3 properties (X, Y, Z), like velocity for example. Make them different to force the position to be unique and independent from other fields.
| Position min | Left lower back corner for the box
| Position max | Right upper front corner for the box
| Target | Allows you to pick up an Entity for the end of the arc. If no Entity is set, Fallback Target will be used, which is an offset from the emitter's location.
| Fallback Target | Offset from the emitter's location used as the end point in case Target is not set
| Arc Height | The height of the arc at its highest point (middle of the distance between the two points). By default it's the Y-up vector, but can be rotated with rotation offset and rotation inheritance
| Ordered | If checked, new particles will appear in order from the emitter towards the target. If unchecked, new particles will appear randomly on the arc anywhere between the emitter and the target. If you plan to visualize the particles as a ribbon or a trail you should set this box to checked.
| Fixed count | By default particles will appear on the arc at distances enough for the maximum number of particles to fit exactly on the line. If you want to control spawn rate and distance, you can set how many fixed "positions" are there on the arc. For example, with a fixed count of 10 and Ordered spawning, the first 10 particles will appear in order, then the 11th particle will appear from the beginning, at the same position as the first, and so on.
| Seed offset | This is used for random numbers. Set it to the same value to force the position to be coupled with other other particle fields which have 3 properties (X, Y, Z), like velocity for example. Make them different to force the position to be unique and independent from other fields.
| Seed offset | This is used for random numbers. Set it to the same value to force the position to be coupled with other particle fields which have 3 properties (X, Y, Z), like velocity for example. Make them different to force the position to be unique and independent from other fields.
| Position min | Left lower back corner for the box. This is an offset in addition to the arc position.
| Position max | Right upper front corner for the box. This is an offset in addition to the arc position.

## Position (parent)

| Property | Description
|-----------------------------|-------------
| Seed offset | This is used for random numbers. Set it to the same value to force the position to be coupled with other other particle fields which have 3 properties (X, Y, Z), like velocity for example. Make them different to force the position to be unique and independent from other fields.
| Seed offset | This is used for random numbers. Set it to the same value to force the position to be coupled with other particle fields which have 3 properties (X, Y, Z), like velocity for example. Make them different to force the position to be unique and independent from other fields.
| Position min | Left lower back corner for the box
| Position max | Right upper front corner for the box
| Parent emitter | You have to type the name of the parent emitter. Child particles' positions will match the parent emitter's particles' positions.
Expand All @@ -154,7 +154,7 @@ The arc position initializer positions the particles in an arc (or a straight li

| Property | Description
|-----------------------------|-------------
| Seed offset | This is used for random numbers. Set it to the same value to force the velocity to be coupled with other other particle fields which have 3 properties (x, Y, Z), like position for example. Make them different to force the velocity to be unique and independent from other fields.
| Seed offset | This is used for random numbers. Set it to the same value to force the velocity to be coupled with other particle fields which have 3 properties (X, Y, Z), like position for example. Make them different to force the velocity to be unique and independent from other fields.
| Velocity min | Left lower back corner for the box
| Velocity max | Right upper front corner for the box
| Parent emitter | You have to type the name of the parent emitter. Child particles' positions will match the parent emitter's particles' positions.
Expand Down
4 changes: 2 additions & 2 deletions en/manual/particles/tutorials/create-a-trail.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ We've created a sword trail effect prefab. Next we'll use a script to spawn the

2. In Visual Studio, right-click the game project and select **Add > New item**. In the **Name** field, give your script the name *SpawnTrail*, and click **Add**.

3. Replace the script content with the code in this script: [SpawnTrail.cs](https://github.com/SiliconStudio/stride-docs/blob/master-1.9/manual/particles/tutorials/media/SpawnTrail.cs)
3. Replace the script content with the code in this script: [SpawnTrail.cs](https://github.com/stride3d/stride-docs/blob/master/en/manual/particles/tutorials/media/SpawnTrail.cs)

This is a modified version of the Prefab Instance script included in Stride. Instead of listening to events or key presses, it listens to animation changes — such as our sword swing animation.

Expand Down Expand Up @@ -316,7 +316,7 @@ We've created a sword trail effect prefab. Next we'll use a script to spawn the

11. In the SpawnTrail component, in the **Animation** field, click the hand icon (**Select an asset**). The **Select an asset** window opens.

In the left pane, select the **mannequinModel** and click **OK**.
In the left pane, select the **mannequinModel** and click **OK**.

![Pick mannequin model in Entity Picker](media/pick-mannequin-model.png)

Expand Down
2 changes: 1 addition & 1 deletion en/manual/particles/tutorials/particle-materials.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ParticleCustomShader : ParticleBase
};
```

It defines two composed shaders, `baseColor` and `abseIntensity`, where we'll plug our generated shaders for RGB and A respectively. It inherits `ParticleBase` which already defines `VSMain`, `PSMain` and texturing, and uses very simple `Shading()` method.
It defines two composed shaders, `baseColor` and `baseIntensity`, where we'll plug our generated shaders for RGB and A respectively. It inherits `ParticleBase` which already defines `VSMain`, `PSMain` and texturing, and uses very simple `Shading()` method.

By overriding the `Shading()` method we can define our custom behavior. Because the composed shaders we use are derived from `ComputeColor`, we can easily evaluate them using `Compute()`, which gives us the root of the compute tree for color and intensity.

Expand Down
6 changes: 6 additions & 0 deletions en/manual/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,12 @@ items:
- name: Create Packages
href: nuget/create-packages.md

- name: Extensibility
href: extensibility/index.md
items:
- name: C# Libraries
href: extensibility/csharp-libraries.md

- name: Troubleshooting
href: troubleshooting/index.md
items:
Expand Down
2 changes: 1 addition & 1 deletion jp/manual/particles/initializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-->

> [!Note]
[アップデーター](updaters.md)には、フレームの**最後**にパーティクルの値を変更することで、イニシャライザーが設定した初期値を効果的に上書きするものもあります。これはすべてのアニメーションに当てはまります。これらはパーティクルの寿命に作用し、色アニメーションアップデーターは、色イニシャライザーが設定した初期値を上書きするでしょう。
> [アップデーター](updaters.md)には、フレームの**最後**にパーティクルの値を変更することで、イニシャライザーが設定した初期値を効果的に上書きするものもあります。これはすべてのアニメーションに当てはまります。これらはパーティクルの寿命に作用し、色アニメーションアップデーターは、色イニシャライザーが設定した初期値を上書きするでしょう。
<!--
> [!Note]
Expand Down
Loading

0 comments on commit a2ef883

Please sign in to comment.