Unity3D

提供: ArchWiki
2021年11月25日 (木) 14:47時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (→‎Visual Studio Code: 一部翻訳)
ナビゲーションに移動 検索に移動

https://unity.com より:

インタラクティブなリアルタイムコンテンツを作成するためのリーディングプラットフォーム
2D、3D、VR のゲームやアプリをスピーディに制作できます。アーティストツールから LiveOps まで、あなたのビジョンを実現するために必要なものがすべて揃っています。

Canonical の Unity (現在、UBPorts Foundationによって保守され、Lomiri に名前が変更されています)とは関係ないので注意してください。

ノート: 今のところ Linux エディタは実験段階です。バグは全て Unity フォーラム に報告してください。

インストール

Unity は Unity Hub と呼ばれるプログラムを提供しています。このプログラムは、Unity プロジェクトを管理できる集中化された場所を提供することでワークフローを合理化し、Unity Editor のインストールの管理、検索、ダウンロードを簡素化します。アプリケーションは AppImage として提供されます。Unity Hub をインストールするには、単に unityhubAUR パッケージをインストールします。

Unity はまだ公式の Linux サポートに取り組んでいる最中なので、ベータ版の方が良い体験を提供できるかもしれません。ベータ版をインストールするには、UnityHubBeta をダウンロードして展開します。このディレクトリで INSTALL.sh スクリプトを実行すると、unityhub beta がインストールされます。

古いパッケージ

歴史的に、他のパッケージがありましたが、それらはすべて古くなっているため、使用しないでください:

警告: こららの歴史的な Unity のパッケージは巨大です。インストールを完了するには、パッケージのビルドに約 17 GiB の空き容量が必要で、インストールするのにはさらに約 8 GiB 必要になります。
ノート:
  • デフォルトでは PKGBUILD は約 2GB のデータをダウンロード・処理するインストーラの出力を全てリダイレクトします。インストールには非常に長い時間がかかるので tail -f /tmp/Unity.log を使って経過を確認することができます。

Android Remote

Unity Remote は Android デバイスでテスト入力をするのに役立つ Android アプリです。圧縮されたスクリーンショットをデバイスの各フレームに送信することでテストができます。

コンピュータの準備

パッケージのインストール

android-udev パッケージをインストールしてください。デバイスの udev ルールが正しく設定されていることを確認します。

android-sdkAUR パッケージと、java-environment のグループからどれか一つパッケージをインストールしてください。OpenJDK で動作することが報告されています。

エディタの設定

エディタを開いて、Edit -> Preferences から Android SDK と JDK の適切なパスを設定してください。

ヒント:
  • Android SDK は通常 /opt/android-sdk にあります。
  • JDK は使用するバージョンによって変わります。デフォルトの JDK を使いたい場合は /usr/lib/jvm/default に設定してください。

Edit -> Project Settings -> Editor から Unity Remote DeviceAny Android Device に設定します。

詳しくは Unity のドキュメント を見て下さい。

Android の準備

Play ストアから Unity Remote 5 をインストールしてください。また、アセットストアからダウンロードして自分でビルドすることもできます。

Android デバイスは PTP モードに設定することが 推奨されています

ノート: デバイスで “USB Debugging” をオンにすることを忘れないで下さい。Settings -> Developer オプションから、USB デバッグを有効にします。Android Jelly Bean 4.2 から開発者オプションはデフォルトで非表示になっています。有効にするには Settings -> About Phone -> Build Version を何回かタップしてください。それで Settings -> Developer オプションを開けるようになります。

詳しくは Unity のドキュメント を見て下さい。

テスト

Unity を起動している場合、終了してください。

携帯端末をコンピュータに接続して Unity Remote を起動します。

エディタを開いてプレイを押して下さい。ゲームが Android デバイスに転送されるのが確認できるはずです。

動作しない場合は、Unity のドキュメント を見て下さい。

Visual Studio Code

Visual Studio Code をスクリプトエディタとして使用している場合は、次のようなエラーを表示させるに実行するために、いくつかの追加の手順が必要です。

[fail]: The reference assemblies for framework ".NETFramework,Version=v3.5" were not found
[warn]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo Unable to create directory "/Debug/". Access to the path "/Debug/" is denied.
[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo Could not write lines to file "/Debug/Assembly-CSharp.csproj.CoreCompileInputs.cache". Could not find a part of the path "/Debug/Assembly-CSharp.csproj.CoreCompileInputs.cache".

To eliminate these errors you need to install the following packages: dotnet-runtime, dotnet-sdk, mono-msbuild, and mono. Finally remember to install the C# extension from the VS Code Marketplace by pressing Ctrl-P and entering:

ext install ms-dotnettools.csharp

You will also want to make sure to set the option for the C#/Omnisharp extension to use the globally installed mono in your path. Add this line to your configuration:

"omnisharp.useGlobalMono": "always"

トラブルシューティング

最初の起動時やサインインするときに Unity がクラッシュする

Unity の設定ファイルが間違って作成されるというレアなバグが存在します。次のコマンドでリセットしてみてください:

$ rm -rf ~/.config/unity3d/{*.prefs,*.log,Preferences} 

プロジェクトをロードしようとすると Unity がクラッシュする

GTK_IM_MODULE の設定を解除することでクラッシュしなくなるという 報告 があります。

~/.config/user-dirs.dirs が存在しない場合に Unity がクラッシュする

xdg ファイルを生成する方法を見て下さい: XDG ユーザーディレクトリ

Unity crashes with DllNotFoundException

In unity 2019 and newer, if you see a message along the lines of: DllNotFoundException: Unable to load the unmanaged library (x) Reason: libtinfo.so: cannot open shared object file: No such file or directory , try installing ncurses5-compat-libsAUR.

Unity fails to build project to webGL plataform

IL2CPP needs libtinfo-5.so library for the building process and ncurses5 provides it. So make sure to install ncurses5-compat-libsAUR if you want to build to webGL.

プレイテスト中にちらつきが発生する (NVIDIA)

NVIDIA のグラフィックカード・ドライバーでは垂直同期が正しく動作しないようです。nvidia-settings を起動して "OpenGL Settings" から "Sync to VBlank" をオフにすることで解決します。

ちらつきは "transform.Rotate" と "Input.GetKey" を組み合わせて使用している場合に発生します。

Error: Multiple Unity instances cannot open the same project

Unity probably did not shutdown properly, in this case you should navigate to your project folder and delete Temp folder.

Android Remote not working / Running Android build fails with "Unable to forward network traffic to device"

Try this workaround :

  1. Close Unity.
  2. Shutdown adb daemon with adb kill-server
  3. Plug in the android device.
  4. Find your device ID with adb devices
  5. Use adb -s "deviceID" forward "tcp:34999" " " replacing "deviceID" with the correct one.

That's it now you can open unity and test it, an error "socket bind failed" will appear that you can safely ignore.

No window opens: Desktop is 0 x 0 @ 0 Hz

If using Wayland, try using the Xorg backend of SDL by setting the environment variable SDL_VIDEODRIVER=x11.

Brotli Invalid ELF Header

If you see an error similar to:

 Failed running python2 "$EDITOR_PATH/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Brotli/python/bro.py"

Either replace the brotli macosx egg with a linux egg at ~/.cache/Python-Eggs/Brotli-0.4.0-py2.7-macosx-10.10-x86_64.egg-tmp, or switch from brotli to gzip:

 File -> Buld Settings -> Player Settings -> Player -> Publishing Settings -> Compression Format
 

Can't Load My Assets In Package Manager

If you have proxy/VPN configured reset it. If you are using iptable resetting it may also work,

 to reset iptable.