コガネブログ

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

【Unity】Duplicate Array Element と Delete Array Element を実行した時は ChangeCheckScope.changed は true にならない

【C#】MethodInfo が拡張メソッドなら true を返す拡張メソッド

C#

ソースコード using System.Reflection; using System.Runtime.CompilerServices; namespace Kogane { public static class MethodInfoExtensionMethods { public static bool IsExtensionMethod( this MethodInfo self ) { return self.IsDefined( typeof( …

【C#】Type が nullable なら true を返す拡張メソッド

C#

ソースコード public static class TypeExtensionMethods { public static bool IsNullable( this Type self ) { return Nullable.GetUnderlyingType( self ) != null; } }

【Jenkins】ビルド日時の環境変数を使用できる「Build Timestamp」紹介

はじめに 「Build Timestamp」を Jenkins に追加することで ビルド日時の環境変数を使用できるようになります 使用例 pipeline { agent any stages { stage('Initialize') { steps { script { echo "${BUILD_TIMESTAMP}" echo "${env.BUILD_TIMESTAMP}" } } …

【Jenkins】Homebrew でインストールした Jenkins を起動したりアップデートしたりするコマンド

概要 # LTS のインストール brew install jenkins-lts # 特定のバージョンの LTS のインストール brew install jenkins-lts@YOUR_VERSION # 起動 brew services start jenkins-lts # 再起動 brew services restart jenkins-lts # アップデート brew upgrade …

【Mac】Homebrew インストール直後に「command not found: brew」と表示される場合

はじめに 公式サイトに書かれているとおりに /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 上記のコマンドを実行して Homebrew インストールした後に brew -v Homebrew が使えるかどうか上記のコマン…

【Unity】EditorGUILayout.Popup で「/」を無視する方法

概要 EditorGUILayout.Popup の displayedOptions に渡す文字列に対して .Replace( "/", "\u2215" ) 上記の処理を行えば「/」で階層が深くならなくなる 参考サイト様

【Unity】CodeEditor.CurrentEditor.OpenProject を使うと指定したファイルを外部コードエディタで開ける

概要 using Unity.CodeEditor; using UnityEditor; public static class Example { [MenuItem( "Tools/Hoge" )] public static void Hoge() { CodeEditor.CurrentEditor.OpenProject ( filePath: "Assets/Example.cs", line: 11, column: 20 ); } } たとえば…

【Unity】Hierarchy の Create メニューから EventSystem が作成できなくなった時の対処方法

概要 EventSystem の Preset を作成して Preset Manager に登録したら Hierarchy の Create メニューから EventSystem が作成できなくなった Unity を再起動したら作成できるように直った 開発環境 Unity 2022.1.11f1 macOS Monterey バージョン 12.5.1

【Unity】キーボード操作で UI が反応しないようにする方法

概要 Event System の Send Navigation Events をオフにする

【Rider】Application のコード補完から UnityEngine.WSA.Application を非表示にする方法

概要 UnityEngine.WSA.Application Auto Import に上記の文字列を追加する

【Rider】Random のコード補完から Unity.Mathematics.Random を非表示にする方法

概要 Unity.Mathematics.Random Auto Import に上記の文字列を追加する

【C#】NPOI でどんなセルの値も文字列で取得できる拡張メソッド

拡張メソッド using NPOI.SS.UserModel; namespace Kogane { public static class ICellExtensionMethods { public static string GetValue( this ICell self ) { if ( self == null ) return string.Empty; return self.CellType switch { CellType.Numeric…

【Unity】選択中の EditorWindow のスクリーンショットを撮影するエディタ拡張

ソースコード using System; using System.IO; using UnityEditor; using UnityEngine; namespace Kogane.Internal { internal static class EditorWindowCapturer { [MenuItem( "Kogane/選択中の EditorWindow をキャプチャ" )] private static void Captur…

【Unity】UnityException: LoadSerializedFileAndForget is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'XXXX'.

概要 [InitializeOnLoad] internal static class Example { static Example() { Debug.Log( ExampleSetting.instance ); } } InitializeOnLoad のタイミングで ScriptableSingleton にアクセスしたら UnityException: LoadSerializedFileAndForget is not al…