LoginSignup
1
1

More than 1 year has passed since last update.

FungusでInputSystemを使う

Last updated at Posted at 2023-01-04

FungusとMRTK3を併用しようとしたら、InputSystemの問題がでてきましたので
以下の記事を参考に、解消していこうと思います。

InputSystemはBothにしていたのですが、古いほうのEventSystemを張り付けても反応がしなかったため、対処していく必要がありそうです。

設定ファイルの修正

まず、FungusのファイルにInputSystem利用に伴う許可設定をいれるため
「Fungus.asmdef」の「Assembly Definition References」に追加をしてApplyしておきます。
aa.png

次に、会話を送る設定をしているcsファイルを探しだします。

ii.png

87行目からの内容を変更します。

jj.png

using UnityEngine.InputSystem;
//割愛
[SerializeField] InputActionReference inputAction;

//89行目あたりを書き換え
 if (inputAction.action.IsPressed())
  {
    SetNextLineFlag();
  }

最後に、設定したいInputSystemをインスペクターから追加して完了です。
bb.png

会話が進行するようになったものの...

isPressedだと反応が良すぎる(1フレームごとの呼び出し)だそうで、
3ページくらいが一気に消化されてしまうようです。
別の何かいい方法がみつかったら追記しようと思います。

※追記
物凄く汚いコードですが、以下で回避しました...
InputSystem側で回避させる方法がありそうなのですが、調べきれませんでした。

 if (inputAction.action.IsPressed() && waitSay)
{
     waitSay = false;
     SetNextLineFlag();
     Invoke("ResetWaiting",2f);
}

//Update以外のところで生成
 private void ResetWaiting()
 {
      waitSay = true;
 }
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1