2020年01月19日

The system cannot find the file specifiedでビルドエラーになる場合

Unityのバージョンを更新した場合などに次のようなビルドエラーになってしまうことがあるようです。

Win32Exception: ApplicationName='...\tools\bin\sdkmanager.bat', CommandLine='--list', CurrentDirectory='...', Native error= The system cannot find the file specified.

そういう場合はUnityを一旦終了させて、Libraryフォルダーを削除してみるとビルドできるようになることもあるみたいです。(自己責任ですが)困っている人は試してみるのも良いかなと思います。

...の部分は省略です。

リンク

Unity Issue Tracker - "The system cannot find file specified" error while opening the project for the first time
https://issuetracker.unity3d.com/issues/the-system-cannot-find-file-specified-error-while-opening-the-project-for-the-first-time
タグ:android
posted by unity-chan at 23:21 | TIPS

2019年12月27日

Unable to locate Android SDKでapkがビルドできない場合

Unity HubでAndroid Buildに必要なモジュールをインストールしているのに

Android SDK not found
Unable to locate Android SDK.

のようなエラーメッセージが表示されてビルドできないという場合は、Android DevelopersからSDK toolsをダウンロードしてみると上手くいく場合があるようです。

手順

  1. Android Developersのサイトから使用したいプラットフォームのZipファイルをダウンロード。
  2. Unity Hubのインストール先の
    Unity/Hub/Unityのバージョン/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/
    にダウンロードしたファイルをunzip。(toolsというディレクトリ名)

ちなみに、SDKディレクトリ内にtoolsディレクトリが存在してる場合はこの方法では解決しないと思いますので、気を付けてください。

リンク

Download Android Studio and SDK tools | Android Developers
https://developer.android.com/studio/

Android SDK not found - Unity Forum
https://forum.unity.com/threads/android-sdk-not-found.762506/
タグ:android Linux
posted by unity-chan at 09:37 | TIPS

2019年12月15日

'SceneCamera' is not valid

Unityで作業をしていたら次のようなエラーメッセージ

transform.position assign attempt for 'SceneCamera' is not valid. Input position is { NaN, NaN, NaN }.

が永遠と表示され、Unityを再起動してもエラーが出続けるという状況に遭遇した場合は、Sceneのタブを「右クリック » Close Tab」して、

Window » General » Scene

から開き直すと回復する場合があるようです。

Unityのバグなのか何か分かりませんが、Webで検索してみると結構古くからある現象みたいです。
posted by unity-chan at 11:02 | TIPS

2019年12月04日

ディレクトリ全体をdiffしたい場合は--dir-diff

git difftoolコマンドを使うとWinMergeとかの外部diffツールが使えます。

色付けできたりして分かりやすく差異を表示できますが、ファイル単位で1つずつdiffされるのが不便で、何か方法を調べてみたところ`--dir-diff`というオプションを使うと一括してdiffできるみたいです。

使い方

git difftool --dir-diff

こんな感じのコマンドでgitの最新バージョンからの差分を一括してdiffできるようになります。

リンク

Git - git-difftool Documentation
https://git-scm.com/docs/git-difftool

WinMerge - You will see the difference…
https://winmerge.org/
タグ:git
posted by unity-chan at 00:17 | TIPS

2019年11月13日

UnityでInput GetKeyを使った操作

Unityでキーボード・ゲームパッドを使ってキャラクターを操作したい場合、

if (Input.GetKey("forward")) {
transform.position += Vector3.forward * Time.deltaTime;
}

のような感じでスクリプトを書くと思います。

ここで使う"forward"とかの文字列は

Edit » Project Settings

にある「Input」の項目から設定できるそうです。

文字列を変更したり、感度等の値を設定したりもできるので、入力関係で細かく設定したい場合は試してみてください。
posted by unity-chan at 01:54 | TIPS