Skip to content

Commit e52b9ae

Browse files
committed
unity system impl doc rewrite
1 parent 22d610c commit e52b9ae

File tree

1 file changed

+51
-16
lines changed

1 file changed

+51
-16
lines changed
Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,66 @@
11
<article>
2-
<h1>Implementing Systems in Unity</h1>
2+
<h1 id="title">Implementing Systems in Unity</h1>
33
<p>
4-
The Ecsact Unity Integration allows implementations of your declared
5-
systems.
4+
The Ecsact Unity integration provides a convenient way to implement your
5+
systems in C# or WebAssembly.
66
</p>
7+
78
<section>
8-
<h2>System Declaration</h2>
9+
<h2 id="csharp-system-impl">C# System Implementation</h2>
10+
<p>
11+
To enable C# system implementations open your Unity project and go to
12+
<strong
13+
>Project Settings <span class="i24">arrow_right</span> Ecsact
14+
<span class="i24">arrow_right</span> System Implementations
15+
</strong>
16+
and change <strong>Source</strong> to <strong>C#</strong>. In addition to
17+
setting the source to C# you must also give a C# Assembly. The specified
18+
C# Assembly must contain your C# system implementation functions. If
19+
you're not familiar with C# Assemblies and Unity, see Unity's
20+
<a
21+
target="_blank"
22+
href="https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html"
23+
><span class="i24">open_in_new</span> Assembly Definitions
24+
documentation</a
25+
>.
26+
</p>
27+
<p></p>
928
<p>
10-
Systems have a <code>C# Attribute</code> in its implementation. The type
11-
name of the system is put here to get the correct <code>context</code>.
12-
The context holds the logic of the system. This includes getting
13-
components, generating entities and retrieving data on actions.
29+
C# System implementations must be a <code>public</code>
30+
<code>static</code> function that returns <code>void</code> with 1
31+
parameter of type <code>EcsactRuntime.SystemExecutionContext</code>. Be
32+
very conscientious of which methods in context are called.
33+
<a routerLink="/docs/system-impl"
34+
>Read more about system implementations to know what can and cannot be
35+
called.</a
36+
>
1437
</p>
38+
<h3>Example</h3>
1539
<code-block-variation>
1640
<pre codeBlockVariationOption><code prism language="csharp">
17-
[Ecsact.DefaultSystemImpl(typeof(example.ExampleSystem))]
18-
public static void AddToExampleSystem(EcsactRuntime.SystemExecutionContext context) {{'{'}}
19-
// Get component from the context
20-
var value = context.Get<{{'example.Example'}}>();
21-
{{'}'}}
41+
[Ecsact.DefaultSystemImpl(typeof(example.ExampleSystem))]
42+
public static void AddToExampleSystem(EcsactRuntime.SystemExecutionContext context) {{'{'}}
43+
// Get component from the context
44+
var myExampleComponent = context.Get<{{'example.Example'}}>();
45+
{{'}'}}
2246
</code></pre>
2347
</code-block-variation>
48+
</section>
2449

50+
<section>
51+
<h2 id="wasm-system-impl">Wasm System Implementations</h2>
2552
<p>
26-
It's essential that the system is both public and static. In addition, it
27-
needs to be part of the assembly that can be generated alongside your
28-
.Ecsact file in <code>edit -> Project Settings -> Ecsact</code>
53+
To enable Wasm system implementations open your Unity project and go to
54+
<strong
55+
>Project Settings <span class="i24">arrow_right</span> Ecsact
56+
<span class="i24">arrow_right</span> System Implementations
57+
</strong>
58+
and change <strong>Source</strong> to <strong>WebAssembly</strong>. A
59+
<code>.wasm</code> file may be specified in these settings for each
60+
system. Learn more about Wasm system implementations in the
61+
<a routerLink="/docs/system-impl-wasm"
62+
>Wasm Systems Overview documentation</a
63+
>.
2964
</p>
3065
</section>
3166
</article>

0 commit comments

Comments
 (0)