コガネブログ

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

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

【Unity】Unity プロジェクトが起動しなくなった時のメモ

概要 Project Settings で「Player > Other Settings > Graphics APIs for Windows」を変更したら Unity プロジェクトが起動できなくなる PC があった Unity プロジェクトを開こうとすると エラーダイアログなど何も表示されずクラッシュする状態だった 「Gr…

【Unity】Android 向けにビルドしたアセットバンドルを Unity エディタで読み込んだ時に TextMesh Pro のテキストが表示されない場合

概要 Unity の Project Settings の「Player > Other Settings」を開く 「Auto Graphics API for Windows」のチェックを外す 「Graphics APIs for Windows」を Android プラットフォームと同じ状態にする Unity を再起動する これで Android 向けにビルドし…

【Unity】uGUI の Slider の値をスクリプトから設定する時に onValueChanged を発生しない関数

概要 using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Slider m_slider; private void Awake() { m_slider.onValueChanged.AddListener( _ => Debug.Log( "ピカチュウ" ) ); // onValueChanged が呼び出される m_s…

【Unity】ScriptableObject に後から PreferBinarySerialization 属性を付与した時にシリアライズし直すエディタ拡張

ソースコード using System.Linq; using UnityEditor; using UnityEngine; public class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var paths = AssetDatabase .FindAssets( $"t:{nameof( ScriptableObject )}" ) .Select( x => A…

【Unity】Unity Test Runner をバッチモードで実行する時にカテゴリで絞り込みする方法

概要 Unity.exe ^ -batchmode ^ -runEditorTests ^ -projectPath "【Unity プロジェクト】" ^ -editorTestsCategories "【カテゴリ名】" ^ -editorTestsResultFile "results.xml" -editorTestsCategories でカテゴリ名を指定する using NUnit.Framework; pub…

【Unity】Too many sprite tiles on Image "XXXX". The tile size will be increased.

概要 Too many sprite tiles on Image "XXXX". The tile size will be increased. To remove the limit on the number of tiles, set the Wrap mode to Repeat in the Image Import Settings UnityEditor.Undo:Internal_CallWillFlushUndoRecord() Image オ…

【Unity】Unity Test Runner をバッチモードで実行する時にテスト名で絞り込みする方法

概要 Unity.exe ^ -batchmode ^ -runEditorTests ^ -projectPath "【Unity プロジェクト】" ^ -editorTestsFilter "【関数名】" ^ -editorTestsResultFile "results.xml" -editorTestsFilter で関数名(部分一致)を指定する 参考サイト様

【Unity】Unity Test Runner のウィンドウをスクリプトから開く方法

概要 using System.Reflection; using UnityEditor; internal static class Example { [MenuItem( "Tools/Example" )] private static void Hoge() { var assembly = Assembly.Load( "UnityEditor.TestRunner" ); var type = assembly.GetType( "UnityEditor…

【Unity】Unity Test Runner の終了コードを受け取る方法

概要 start /WAIT "" "Unity.exe" ^ -batchmode ^ -runEditorTests ^ -projectPath "【Unity プロジェクト】" ^ -editorTestsResultFile "results.xml" echo %ERRORLEVEL% 上記のようなコマンドを実行すると %ERRORLEVEL% で終了コードを受け取れる 0: テス…

【Unity】Unity Test Runner の開始終了を検知する方法

概要 using UnityEditor; using UnityEditor.TestTools.TestRunner.Api; using UnityEngine; [InitializeOnLoad] internal sealed class Example : ICallbacks { static Example() { var api = ScriptableObject.CreateInstance<TestRunnerApi>(); api.RegisterCallbacks( n</testrunnerapi>…

【Unity】Unity Test Runner をスクリプトから実行する方法

概要 using UnityEditor; using UnityEditor.TestTools.TestRunner.Api; using UnityEngine; internal static class Example { [MenuItem( "Tools/Run Play Mode" )] private static void RunPlayMode() { RunTest( TestMode.PlayMode ); } [MenuItem( "Tool…

【Unity】Addressable Asset System でアセットが削除された時にグループを更新しないようにするエディタ拡張

ソースコード

【Unity】変更した SceneSetup を簡単に元に戻せるクラス

ソースコード using System; using UnityEditor.SceneManagement; public sealed class SceneSetupScope : IDisposable { private readonly SceneSetup[] m_oldSetups; public SceneSetupScope() { m_oldSetups = EditorSceneManager.GetSceneManagerSetup()…

【Unity】ファイルを開くアプリケーションを設定できるエディタ拡張「UniOpenAssetCustomizer」を GitHub に公開しました

リポジトリ 使い方 Unity の Preferences の左メニューから「UniOpenAssetCustomizer」を開くことで、 ファイルを開くアプリケーションを拡張子ごとに設定できます 項目 内容 Extension 対象の拡張子(「.」は不要) Application Path ファイルを開くアプリ…

【Unity】コンパイル時間を計測するエディタ拡張「UniCompileTimeMeasurer」を GitHub に公開しました

リポジトリ 使い方 Preferences の「UniCompileTimeMeasurer」の項目を開いて 「Enabled」をオンにすることでコンパイル時間が計測されるようになります 計測されたコンパイル時間は Unity メニューの「Window > UniCompileTimeMeasurer」から確認できます

【Unity】Console ウィンドウを操作する internal な機能を使用できるようにするパッケージ「UniLogEntriesInternal」を GitHub に公開しました

リポジトリ 使用例 using UniLogEntriesInternal; using UnityEditor; using UnityEngine; public class Example { [MenuItem( "Tools/Log" )] private static void Log() { int count = 3; for ( int i = 0; i < count; i++ ) { Debug.Log( "ピカチュウ" );…

【Unity】Color 型と16進数、HTML カラー形式の文字列の変換ができる機能「UniColorUtils」を GitHub に公開しました

リポジトリ 使用例 using UniColorUtils; using UnityEngine; public class Example : MonoBehaviour { private void Start() { // RGBA(1.000, 0.502, 0.000, 1.000) Debug.Log( ColorUtils.FromRGB( 255, 128, 0 ) ); // RGBA(1.000, 0.502, 0.000, 1.000)…