0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Unity 6(2023 LTS)で Cinemachine の using が変更されていた話

Posted at

2024年まで、Unity で Cinemachine をスクリプトで利用するときは以下のように書くのが一般的でした。

using Cinemachine;

ところが Unity 6(正式リリース名:Unity 2023 LTS) では、Cinemachine の using が変更されており、このままではエラーになってしまいます。

新しい形では以下のように書く必要があります。

using Unity.Cinemachine;
using Unity.Cinemachine.Editor;
using Unity.Cinemachine.TargetTracking;

「あれ?Cinemachine が使えなくなった!!」
と思って調べたのですが、意外と検索では情報を拾えなかったので共有しておきます。

Unity 6(2023 LTS)は最新だし、ひとまず使っておけば間違いないだろう… と気軽にアップデートした結果、変更による違いを把握していなかったため困ることになりました(^▽^;)

同じ状況になった方の参考になればと思います。


Cinemachine の変更点(Unity 6 / 2023 LTS)

Unity 6(2023 LTS)では、Cinemachine のデフォルトバージョンが Cinemachine 3 系 になっており、いくつかの API に破壊的変更が加えられています。

名前空間の変更

旧バージョン(Unity 2022 まで) 新バージョン(Unity 6 / 2023 LTS)
using Cinemachine; using Unity.Cinemachine;
using Cinemachine.Editor; using Unity.Cinemachine.Editor;
using Cinemachine.Utility; Unity.Cinemachine に統合

対応方法

  1. スクリプトの修正

旧 using を新しい名前空間に置き換えます。

変更前 (Unity 2022 以前)

using Cinemachine;

変更後 (Unity 6 / 2023 LTS)

using Unity.Cinemachine;

もし Cinemachine.Editor を使用している場合は、Unity.Cinemachine.Editor に変更してください。
2. アセンブリ定義ファイル(.asmdef)の更新

プロジェクト内で アセンブリ定義ファイル を使っている場合、Cinemachine への参照を更新する必要があります。

更新方法
対象の .asmdef ファイル を選択
Inspector ウィンドウで「Assembly Definition References」を確認
Unity.Cinemachine を追加
不要な参照(Missing Reference など)があれば削除
Apply ボタンをクリックして適用

  1. プロジェクトのリフレッシュ

すべての変更を保存した後、Assets > Refresh を実行してプロジェクトをリフレッシュしましょう。

まとめ

Unity 6 では Cinemachine のバージョンが 3.x に更新され、名前空間が変更されました。
using Cinemachine; ではなく、 using Unity.Cinemachine; を使用する必要があります。

「Cinemachine が急に使えなくなった!」 という方は、上記の対応を試してみてください!

📝 公式リリースノート:
https://unity.com/ja/releases/unity-6

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?