-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters