From 969870ee67f010dd6d018160d593212ef5154e39 Mon Sep 17 00:00:00 2001 From: mewlist Date: Thu, 22 Feb 2024 23:03:48 +0900 Subject: [PATCH] Add tickable document --- Writerside~/di.tree | 1 + Writerside~/di_en.tree | 1 + Writerside~/topics/tickable.md | 47 +++++++++++++++++++++++++++++++ Writerside~/topics/tickable_en.md | 45 +++++++++++++++++++++++++++++ Writerside~/topics/tutorial.md | 22 +++++++++++---- Writerside~/topics/tutorial_en.md | 22 +++++++++++---- 6 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 Writerside~/topics/tickable.md create mode 100644 Writerside~/topics/tickable_en.md diff --git a/Writerside~/di.tree b/Writerside~/di.tree index 17a5689..bb97f60 100644 --- a/Writerside~/di.tree +++ b/Writerside~/di.tree @@ -30,6 +30,7 @@ + \ No newline at end of file diff --git a/Writerside~/di_en.tree b/Writerside~/di_en.tree index 04d3efa..76b0838 100644 --- a/Writerside~/di_en.tree +++ b/Writerside~/di_en.tree @@ -30,6 +30,7 @@ + \ No newline at end of file diff --git a/Writerside~/topics/tickable.md b/Writerside~/topics/tickable.md new file mode 100644 index 0000000..2fa3c98 --- /dev/null +++ b/Writerside~/topics/tickable.md @@ -0,0 +1,47 @@ +# 定期的なコールバック + +Unity のプレイヤーループタイミングに従って、定期的に呼び出されるコールバックを登録できます。 +DI コンテナにより管理されるインスタンスや、注入対象となるインスタンスに対して機能します。 +また、対象のクラスへの注入が完了した以降に初回の呼び出しが行われることが保証されます。 + +## コールバックの登録 + +任意の public なメソッドに ```[Tickable]``` 属性をつけることで、コールバックを登録できます。 +タイミングを指定しなかった場合は、```Update``` タイミングでコールバックされます。 + +```C# +public class SomeClass +{ + // Update タイミングで呼び出される + [Tickable] + public void Tick() + { + ... + } +} +``` + +## コールバックタイミングの指定 + +```Tickable``` の引数にコールバックのタイミングを指定できます。 + +```C# +public class SomeClass +{ + // FixedUpdate タイミングで呼び出される + [Tickable(TickableTiming.FixedUpdate)] + public void Tick() + { + ... + } +} +``` + +コールバックには以下のタイミングを指定できます。 + +* TickableTiming.EarlyUpdate +* TickableTiming.FixedUpdate +* TickableTiming.PreUpdate +* TickableTiming.Update +* TickableTiming.PreLateUpdate +* TickableTiming.PostLateUpdate diff --git a/Writerside~/topics/tickable_en.md b/Writerside~/topics/tickable_en.md new file mode 100644 index 0000000..0652385 --- /dev/null +++ b/Writerside~/topics/tickable_en.md @@ -0,0 +1,45 @@ +# Regular Callbacks + +You can register callbacks that are called regularly according to the timing of Unity's player loop. +It works for instances managed by the DI container and instances to be injected. It is also guaranteed that the first call will be made after the injection to the target class has been completed. + +## Registering Callbacks + +By adding the ```[Tickable]``` attribute to any public method, you can register a callback. If you do not specify the timing, it will be called back at the ```Update``` timing. + +```C# +public class SomeClass +{ + // Called at Update timing + [Tickable] + public void Tick() + { + ... + } +} +``` + +## Specifying Callback Timing + +You can specify the timing of the callback in the arguments of ```Tickable```. + +```C# +public class SomeClass +{ + // Called at FixedUpdate timing + [Tickable(TickableTiming.FixedUpdate)] + public void Tick() + { + ... + } +} +``` + +You can specify the following timings for the callback. + +* TickableTiming.EarlyUpdate +* TickableTiming.FixedUpdate +* TickableTiming.PreUpdate +* TickableTiming.Update +* TickableTiming.PreLateUpdate +* TickableTiming.PostLateUpdate \ No newline at end of file diff --git a/Writerside~/topics/tutorial.md b/Writerside~/topics/tutorial.md index b92e596..89e318f 100644 --- a/Writerside~/topics/tutorial.md +++ b/Writerside~/topics/tutorial.md @@ -11,9 +11,14 @@ Unity Package Manager からインストールすることができます。 Unity のメニューから Window > Package Manager を選択します。 + ボタンをクリックし、Add package from git URL... を選択します。 以下を入力し、Add をクリックします。 - -git@github.com:mewlist/MewCore.git - + + +https://github.com/mewlist/MewCore.git + + +git@github.com:mewlist/MewCore.git + + @@ -24,9 +29,14 @@ git@github.com:mewlist/MewCore.git Unity のメニューから Window > Package Manager を選択します。 + ボタンをクリックし、Add package from git URL... を選択します。 以下を入力し、Add をクリックします。 - -git@github.com:mewlist/Doinject.git - + + +https://github.com/mewlist/Doinject.git + + +git@github.com:mewlist/Doinject.git + + diff --git a/Writerside~/topics/tutorial_en.md b/Writerside~/topics/tutorial_en.md index c3b97de..14c06bd 100644 --- a/Writerside~/topics/tutorial_en.md +++ b/Writerside~/topics/tutorial_en.md @@ -11,9 +11,14 @@ You can install it from the Unity Package Manager. Select Window > Package Manager from the Unity menu. Click the + button and select Add package from git URL.... Enter the following and click Add. - -git@github.com:mewlist/MewCore.git - + + +https://github.com/mewlist/MewCore.git + + +git@github.com:mewlist/MewCore.git + + @@ -24,9 +29,14 @@ git@github.com:mewlist/MewCore.git Select Window > Package Manager from the Unity menu. Click the + button and select Add package from git URL.... Enter the following and click Add. - -git@github.com:mewlist/Doinject.git - + + +https://github.com/mewlist/Doinject.git + + +git@github.com:mewlist/Doinject.git + +