コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

2022-01-01から1ヶ月間の記事一覧

【Unity】Unity 2021.2 で並列インポートを使うとインポートがどれだけ速くなるか

検証内容 テクスチャと 3D モデルが合計約 4,000 個存在する Unity プロジェクトで検証 Library フォルダを削除した状態でプロジェクトを開くのにかかる時間を計測 並列インポートが有効な場合と無効な場合でかかった時間を比較 並列インポート有効時の設定…

【Rider】複数ファイル内検索で Unity の .meta ファイルも検索対象にする方法

概要 複数ファイル内検索で「ファイルマスク」をチェックして *.meta と入力し、 さらに「Include non-solution items」をチェックした状態で検索すると Unity の .meta ファイル内も検索することができます

【Unity】Addressables を導入しているプロジェクトでビルドすると定期的に数 KB の GC Alloc が発生する場合

概要 Addressables を導入しているプロジェクトからゲームをビルドして Profiler を見た時に 「DiagnosticEventCollectorSingleton.Update()」というプロセスで 1.2 KB の GC Alloc が定期的に発生している場合 AddressableAssetSettings の「Send Profiler …

【Unity】Addressables を導入しているプロジェクトで再生に時間がかかる場合は AssetReference が原因の可能性がある

概要 Addressables 1.18.16 あたりから AssetReference のコンストラクタで /// <summary> /// Construct a new AssetReference object. /// </summary> public AssetReference() { #if UNITY_EDITOR EditorApplication.playModeStateChanged -= ReleaseHandleWhenPlaymodeState…

【Unity】Addressables のビルド時間の内訳を Chrome で確認する方法

概要 Chrome を開いてアドレスバーに chrome://tracing と入力します Load ボタンを押して Unity プロジェクトのフォルダに存在する Library/com.unity.addressables/AddressablesBuildTEP.json を選択します これで Addressables のビルド時間の内訳を Chro…

【Unity】Addressables でビルドした時にビルド結果の詳細を出力する方法

概要 Unity の Preferences を開いて左メニューで「Addressables」を選択して 「Debug Build Layout」をオンにした状態で Addressables でビルドすると ビルド結果の詳細が Library/com.unity.addressables/ フォルダに buildlayout.txt というファイルで出…

【Unity】Addressables で Android の Play Asset Delivery に対応する公式サンプル

概要 上記の公式の Addressables のサンプルリポジトリの 「Advanced > Play Asset Delivery」フォルダに Addressables で Android の Play Asset Delivery に対応する サンプルプロジェクトが格納されています

【Unity】Android において Addressables でローカルアセットバンドルの読み込みにも UnityWebRequest を使用すると読み込みが速くなる場合がある

概要 Addressables のグループの Inspector で 「Use UnityWebRequest for Local Asset Bundles」をオンにすると Android でローカルアセットバンドルの読み込みが速くなる場合があります 参考サイト様

【Unity】Addressables で CRC を無効にするとアセットバンドルの読み込みが速くなる場合がある

概要 Addressables のグループの Inspector で「Asset Bundle CRC」を「Disabled」にすると アセットバンドルの読み込みが速くなる場合があります 参考サイト様

【Unity】AssetReference からアドレスを取得する方法

ソースコード using System.Linq; using UnityEngine; using UnityEngine.AddressableAssets; public sealed class Example : MonoBehaviour { public AssetReference m_assetReference; private void Start() { var handle = Addressables.LoadResourceLoca…

【Unity】Unity 2021.2 でプロジェクトのインポートにかかった時間の詳細を確認する方法

概要 Unity メニューの「Window > Analysis > Import Activity」を選択するか Project ウィンドウでアセットを右クリックして 「View in Import Activity Window」を選択するか Inspector のタブを右クリックして「Open in Import Activity Window」を選択す…

【Unity】Unity 2021.2 でアセットのインポート時に使用された AssetPostprocessor を確認する方法

概要 アセットの Inspector の「Asset PostProcessors」の欄を開くと そのアセットのインポート時に使用された AssetPostprocessor を一覧で確認できます

【Unity】ゲームをビルドする時に自動で Addressables のビルドを実行する方法

検証環境 Unity 2021.2.7f1 Addressables 1.19.15 概要 AddressableAssetSettings の Inspector の 「Build > Build Addressables on Player Build」を変更することで ゲームをビルドする時に自動で Addressables のビルドを実行できるようになります 項目 …

【Unity】Unity 2021.2 でアセットの並列インポートを有効にする方法

概要 Unity メニューの「Edit > Project Settings」を開いて 左メニューで「Editor」を選択して「Parallel Import」をオンにすると アセットの並列インポートを有効化できます 記事執筆時点で並列インポートに対応しているアセットは以下のとおりです Textur…

【Unity】Addressables で各グループの BundledAssetGroupSchema の Build Path や Load Path の名前を取得するサンプル

ソースコード using System.Linq; using UnityEditor; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Settings.GroupSchemas; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] public static vo…

【Unity】Unity 2020.3 から 2021.2 でテクスチャのインポート時間がどれだけ短縮されたか計測

はじめに 100 個のテクスチャが格納されている Unity プロジェクトで [MenuItem( "Tools/Reimport" )] public static void Reimport() { var sw = Stopwatch.StartNew(); AssetDatabase.ImportAsset ( "Assets/Textures", ImportAssetOptions.ForceUpdate | …

【Unity】エディタ拡張で Project Template を保存する関数

ソースコード using System.Reflection; using UnityEditor; using UnityEngine.Assertions; public static class EditorUtilityInternal { public static void SaveProjectAsTemplate ( string targetPath, string name, string displayName, string descri…

【Unity】Building Library\Bee\artifacts\Android\Manifest\LauncherManifestDiag.txt failed with output:

概要 Building Library\Bee\artifacts\Android\Manifest\LauncherManifestDiag.txt failed with output: System.Xml.XmlException: Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 29, position 5. at System.Xml.XmlTextReaderIm…

【Unity】Hierarchy を右クリックして UI を作成できなくなった場合

概要 Hierarchy を右クリックした時に「UI」という項目が表示されておらず UI を作成できなくなった場合、 Unity メニューの「GameObject > UI」から UI を作成できる 参考サイト様

【Marp】Marp CLI で PDF に変換する時に HTML タグが反映されない場合

概要 ./bin/marp.exe ^ --pdf ^ 【.md のファイルパス】 ^ --html ^ --theme custom-theme.css ^ --allow-local-files --pdf で出力する場合にも --html を指定すると Marp CLI で PDF に変換する時に HTML タグが反映されるようになる 参考サイト様

【Marp】M PLUS 1p を使う方法

Markdown --- marp: true theme: uncover --- <style> @import url('https://fonts.googleapis.com/css?family=M+PLUS+1p'); section { font-family: 'M PLUS 1p'; } </style> # タイトル --- ## スライド 1 * 箇条書き 1 * 箇条書き 2 * 箇条書き 3 適用前 適用後 参考サイ…

【Marp】Noto Sans Japanese を使う方法

Markdown --- marp: true theme: uncover --- <style> @import url('https://fonts.googleapis.com/css?family=Noto+Sans+JP'); section { font-family: 'Noto Sans JP'; } </style> # タイトル --- ## スライド 1 * 箇条書き 1 * 箇条書き 2 * 箇条書き 3 適用前 適用後 参…

【雑記】コマンドプロンプトからネットワーク接続の ON / OFF を切り替える方法

概要 netsh interface show interface まずコマンドプロンプトで上記のコマンドを実行します するとネットワーク接続の一覧が表示されるので コマンドプロンプトから接続を切り替えたいネットワークの 「Interface Name」を覚えておきます netsh interface s…

【雑記】Google アナリティクスで訪問者さんが使用しているモニターの解像度を調べる方法

概要 Google アナリティクスの左メニューで 「ユーザー > テクノロジー > ブラウザと OS」を選択した後に 「画面の解像度」を選択すると、訪問者さんが使用している モニターの解像度の割合を確認できる ブログのレイアウトを考える時の参考にできる

【Python】exe 化する方法

概要 pip install pyinstaller 事前に pip install で pyinstaller をインストールしておく pyinstaller 【Python のファイルパス】 --onefile 後は上記のコマンドで指定した Python スクリプトを exe 化できる 作成された exe は dist フォルダに出力される

【Python】urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

概要 urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)> Mac で Python を実行したら上記のエラーが発生した /Applications/Python 3.XX/Install Certificates.command 上記のファイルをダブルクリックして実行したらエラーが発生しなくなった 参考サイト様</urlopen>

【PowerShell】このシステムではスクリプトの実行が無効になっているため、ファイル XXXX.ps1 を読み込むことができません

概要 このシステムではスクリプトの実行が無効になっているため、 ファイル XXXX.ps1 を読み込むことができません。詳細については、 「about_Execution_Policies」(https://go.microsoft.com/fwlink/?LinkID=135170) を参照してください。 PowerShell のス…

【Docker】The WSL 2 Linux kernel is now installed using a separate MSI update package.

概要 WSL 2 installation is incomplete. The WSL 2 Linux kernel is now installed using a separate MSI update package. Please click the link and follow the instructions to install the kernel update: https://aka.ms/wsl2kernel. Press Restart af…

【Docker】Hardware assisted virtualization and data execution protection must be enabled in the BIOS.

概要 An unexpected error occurred Hardware assisted virtualization and data execution protection must be enabled in the BIOS. See https://docs.docker.com/desktop/windows/troubleshoot/#virtualization Docker Desktop を起動しようとしたら上記…

【C#】指定した倍数で四捨五入のように丸める関数

C#

ソースコード public static class MathUtils { public static double RoundByMultiple( double value, double unit ) { return Math.Round( value / unit ) * unit; } } 使用例 Console.WriteLine( MathUtils.RoundByMultiple( 0.26, 0.25 ) ); // 0.25 Con…