Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #25 from umm/support_upm
Browse files Browse the repository at this point in the history
Support UPM
  • Loading branch information
milkcocoa authored Mar 15, 2020
2 parents c8804b4 + 9c1238a commit 53e014e
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 61 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/publish-upm-package.yml
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 }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://upm-packages.dev
1 change: 1 addition & 0 deletions Assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
7 changes: 7 additions & 0 deletions Assets/CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions Assets/README.md
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) からダウンロードしております
7 changes: 7 additions & 0 deletions Assets/README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions Assets/package.json
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"
}
}
7 changes: 7 additions & 0 deletions Assets/package.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CHANGELOG.md
60 changes: 0 additions & 60 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umm/animationevent_dispatcher",
"version": "1.4.2",
"version": "1.5.0",
"description": "Dispatch AnimationEvent by Animation",
"homepage": "https://github.com/umm/animationevent_dispatcher",
"bugs": {
Expand Down

0 comments on commit 53e014e

Please sign in to comment.