ラベル Unity の投稿を表示しています。 すべての投稿を表示
ラベル Unity の投稿を表示しています。 すべての投稿を表示

2021年5月31日月曜日

Linux版 UnityHub の headless に対応した Docker image

Linux 版 Unity 使いたいので UnityHub CLI でインストールしようと思ったらめんどくさかったので備忘録。

Feedback - Headless Mode Isn't Really Headless - Unity Forum

なにが面倒だったというと、 headless モードが headless モードじゃなくて docker とか VM とかでディスプレイない環境だと起動ができないのです。

こんな感じのエラーで起動できません。

(unityhub-bin:919): Gtk-WARNING **: 08:08:17.580: cannot open display: 

で、xvfb で回避できるのですが、すでに回避策を講じた Docker image を同僚に教えてもらいました。このイメージを使ったら Unity のインストールとかの自動化も簡単にできそうです。
https://hub.docker.com/u/unityci

Dockerfile はこれ
https://github.com/game-ci/docker/blob/main/hub/Dockerfile

中身を読むとわかりますが、AppImage をばらして xvfb-run してます。
ちょっと気になるのは、ばらした AppImage が / に展開されることくらいですかねぇ。
Docker なら、まぁいいかもしれませんがどこかのインスタンスに入れるなら嫌だなぁと思ったので、自分なりに書き直してみました。

書き直し
イメージ

できあがったイメージと Dockerfile はこちらです。
https://hub.docker.com/r/srzzumix/unityhub
https://github.com/srz-zumix/docker-unityhub

書き直してわかったポイント

PR のコメントとして残してあります。

  • unityci/hub image は APPDIR が未定義なため / で実行されていた
  • zenity がないと unityhub-bin 起動後に進まなかった
  • ~/.config/Unity Hub/eulaAccepted ファイルを作成して EULA 確認をスキップ
  • unityhub.desktop ファイルにバージョンが書いてある
  • Mac 版だと -- --headless help のようにオプションを指定するが Linux 版で -- つけると先に進まない

以上、回避策など取らずに使えるようになってくれると嬉しいですね。では。

2018年6月14日木曜日

[Unity] メタァ・・・なんで忘れてしまうん・・・

Unity で .meta ファイルが commit されてなくて困ったってのをよく見かけるので書いた。

メタファイルをコミットしてない、かつ、対象のファイルがコミットされていると commit/push 禁止するフックスクリプト。


コミットされているかどうかの判定がびみょいが、まぁ使えるはず

2018年2月6日火曜日

Unity で警告を一括抑制する方法

Unity - マニュアル: PlatformDependentCompilation (current)
Unity のマニュアルにあるように、mcs.rsp ファイルで制御します。
※ mcs.rsp は以前のバージョンでは、smcs と gmcs に分かれていたようです。
Unity - マニュアル: PlatformDependentCompilation (5.4)
ファイル名はお使いのバージョンに合わせてください。

C# 全般の抑制をしたい場合は mcs.rsp に、Visual Studio の警告を抑止したい場合は csc.rsp を
Assets フォルダーに追加します。

rsp ファイルでは警告抑止以外のことも制御することができます。(define とか)
rsp ファイルで指定できることはヘルプで確認できます。
Unity のインストールディレクトリの Editor 以下のどこかに mcs があるので、mcs --help を実行します。
※筆者環境では C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\bin にありました(Windows 10/Unity 2017.3)
C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\bin>mcs --help
Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc
mcs [options] source-files
   --about              About the Mono C# compiler
   -addmodule:M1[,Mn]   Adds the module to the generated assembly
   -checked[+|-]        Sets default aritmetic overflow context
   -clscheck[+|-]       Disables CLS Compliance verifications
   -codepage:ID         Sets code page to the one in ID (number, utf8, reset)
   -define:S1[;S2]      Defines one or more conditional symbols (short: -d)
   -debug[+|-], -g      Generate debugging information
   -delaysign[+|-]      Only insert the public key into the assembly (no signing)
   -doc:FILE            Process documentation comments to XML file
   -fullpaths           Any issued error or warning uses absolute file path
   -help                Lists all compiler options (short: -?)
   -keycontainer:NAME   The key pair container used to sign the output assembly
   -keyfile:FILE        The key file used to strongname the ouput assembly
   -langversion:TEXT    Specifies language version: ISO-1, ISO-2, 3, 4, 5, 6, Default or Experimental
   -lib:PATH1[,PATHn]   Specifies the location of referenced assemblies
   -main:CLASS          Specifies the class with the Main method (short: -m)
   -noconfig            Disables implicitly referenced assemblies
   -nostdlib[+|-]       Does not reference mscorlib.dll library
   -nowarn:W1[,Wn]      Suppress one or more compiler warnings
   -optimize[+|-]       Enables advanced compiler optimizations (short: -o)
   -out:FILE            Specifies output assembly name
   -pathmap:K=V[,Kn=Vn] Sets a mapping for source path names used in generated output
   -pkg:P1[,Pn]         References packages P1..Pn
   -platform:ARCH       Specifies the target platform of the output assembly
                        ARCH can be one of: anycpu, anycpu32bitpreferred, arm,
                        x86, x64 or itanium. The default is anycpu.
   -recurse:SPEC        Recursively compiles files according to SPEC pattern
   -reference:A1[,An]   Imports metadata from the specified assembly (short: -r)
   -reference:ALIAS=A   Imports metadata using specified extern alias (short: -r)
   -sdk:VERSION         Specifies SDK version of referenced assemblies
                        VERSION can be one of: 2, 4, 4.5 (default) or a custom value
   -target:KIND         Specifies the format of the output assembly (short: -t)
                        KIND can be one of: exe, winexe, library, module
   -unsafe[+|-]         Allows to compile code which uses unsafe keyword
   -warnaserror[+|-]    Treats all warnings as errors
   -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors
   -warn:0-4            Sets warning level, the default is 4 (short -w:)
   -helpinternal        Shows internal and advanced compiler options

Resources:
   -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)
   -resource:FILE[,ID]     Embed FILE as a resource (short: -res)
   -win32res:FILE          Specifies Win32 resource file (.res)
   -win32icon:FILE         Use this icon for the output
   @file                   Read response file for more options

Options can be of the form -option or /option

もしくはこちらでも確認できます。(たぶん同じ(/ と - が異なるけど)
カテゴリ別の C# コンパイラ オプションの一覧 (C#)
/nowarn (指定した警告の非表示) (C#)

警告を抑止
肝心の警告抑止ですが、mcs.rsp (場合によって csc/smcs/gmcs)に以下を記述します。
-nowarn:0649

今回は以上です。
Unity の記事を書く日が来るとはねぇ。数年前の自分からは考えられないことやね。