This repository has been archived by the owner on Dec 6, 2021. It is now read-only.
-
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.
Merge pull request #25 from umm/support_upm
Support UPM
- Loading branch information
Showing
11 changed files
with
155 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Publish UPM Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: monry/actions-upm-publish@v1 | ||
with: | ||
npm_auth_token: ${{ secrets.NPM_AUTH_TOKEN }} |
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 @@ | ||
registry=https://upm-packages.dev |
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 @@ | ||
# Changelog |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,90 @@ | ||
# What? | ||
|
||
* Animation の AnimationEvent 機能から呼び出し可能な汎用 Dispatcher | ||
|
||
# Why? | ||
|
||
* エンジニアとデザイナー (アニメーター) とのコミュニケーションコストを下げたかった | ||
* 先に Script 側にメソッド定義していないと AnimationEvent で呼び出しできない | ||
* しかし Script が先行して実装されているケースが少ない | ||
* そのため、コミュニケーションの往復回数が多くなる | ||
|
||
# Install | ||
|
||
### With Unity Package Manager | ||
|
||
```bash | ||
upm add package dev.upm-packages.animationevent-dispatcher | ||
``` | ||
|
||
Note: `upm` command is provided by [this repository](https://github.com/upm-packages/upm-cli). | ||
|
||
You can also edit `Packages/manifest.json` directly. | ||
|
||
```jsonc | ||
{ | ||
"dependencies": { | ||
// (snip) | ||
"dev.upm-packages.animationevent-dispatcher": "[latest version]", | ||
// (snip) | ||
}, | ||
"scopedRegistries": [ | ||
{ | ||
"name": "Unofficial Unity Package Manager Registry", | ||
"url": "https://upm-packages.dev", | ||
"scopes": [ | ||
"dev.upm-packages" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Any other else (classical umm style) | ||
|
||
```shell | ||
$ npm install github:umm/animationevent_dispatcher.git | ||
``` | ||
|
||
# Usage | ||
|
||
## GeneralDispatcher | ||
|
||
### Animation 側 | ||
|
||
* AnimatorController がアタッチされている GameObject に `GeneralDispatcher` をアタッチします | ||
* Animation の AnimationEvent の設定として `GeneralDispatcher.Dispatch()` を呼び出します | ||
* その際、1つ以上の `int`, `float`, `string`, `object` をパラメータとして渡せます | ||
* `string` を用いて「何の AnimationEvent なのか?」を渡すと見通しが良くなりそうです | ||
|
||
### Script 側 | ||
|
||
* `GeneralDispatcher.OnDispatchAsObservable()` が返す `IObservable<AnimationEvent>` を Subscribe します | ||
* `OnDispatchAsObservable()` *引数: なし* は全ての `AnimationEvent` を流します | ||
* `.Where()` などでフィルタリングすることをオススメします | ||
* `OnDispatchAsObservable()` *引数: int, float, string, object* は引数に渡した値にマッチする `AnimationEvent` を流します | ||
* 複合条件には対応していないので、複雑な条件を付ける場合は *引数なし* を呼んで、自分でストリームをフィルタしてください | ||
|
||
## AudioDispatcher | ||
|
||
### Animation 側 | ||
|
||
* AnimatorController がアタッチされている GameObject に `AudioDispatcher` をアタッチします | ||
* Animation の AnimationEvent の設定として `AudioDispatcher.Play()` を呼び出します | ||
* その際、 AudioClip をパラメータとして渡します | ||
* これで、当該 AnimationEvent を通過した瞬間にパラメータに渡した AudioClip が再生されます | ||
|
||
### Script 側 | ||
|
||
* 「発音が始まった瞬間」を検知することができます | ||
* 検知する場合は `AudioDispatcher.OnDispatchAsObservable()` が返す `IObservable<AnimationEvent>` を Subscribe します | ||
|
||
# License | ||
|
||
Copyright (c) 2017 Tetsuya Mori | ||
|
||
Released under the MIT license, see [LICENSE.txt](LICENSE.txt) | ||
|
||
## Included Asset | ||
|
||
* テスト用の音声ファイル (`Assets/Tests/Sounds/Audio.mp3`) は [無料効果音素材](http://taira-komori.jpn.org/freesound.html) からダウンロードしております |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,23 @@ | ||
{ | ||
"name": "dev.upm-packages.animationevent-dispatcher", | ||
"displayName": "AnimationEvent Dispatcher", | ||
"version": "1.5.0", | ||
"unity": "2019.3", | ||
"description": "Dispatch AnimationEvent by Animation", | ||
"author": { | ||
"name": "Tetsuya Mori", | ||
"url": "https://me.monry.dev/", | ||
"email": "[email protected]" | ||
}, | ||
"license": "MIT", | ||
"keywords": [""], | ||
"category": "", | ||
"dependencies": { | ||
"com.stevevermeulen.extenject": "9.1.0-5", | ||
"jp.cysharp.unirx": "7.1.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/umm/animationevent_dispatcher" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
Assets/CHANGELOG.md |
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 @@ | ||
Assets/README.md |
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