コガネブログ

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

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

【Unity】ドッキングされている EditorWindow の maxSize は無視される

参考サイト様

【Rider】Array のコード補完から NPOI.HPSF.Array を非表示にする方法

概要 NPOI.HPSF.Array Auto Import に上記の文字列を追加する

【Unity】Visual Element の相対位置を取得する方法

概要 Debug.Log( element.layout.position );

【Unity】Visual Element の絶対位置を取得する拡張メソッド

ソースコード using UnityEngine; using UnityEngine.UIElements; namespace Kogane { public static class VisualElementExtensionMethods { public static Vector2 GetPosition( this VisualElement self ) { var element = self; var position = Vector2.…

【Rider】Assembly のコード補完から UnityEditor.Compilation.Assembly を非表示にする方法

概要 UnityEditor.Compilation.Assembly Auto Import に上記の文字列を追加する

【Rider】Task のコード補完から UnityEditor.VersionControl.Task を非表示にする方法

概要 UnityEditor.VersionControl.Task Auto Import に上記の文字列を追加する

【Rider】Type のコード補完から Mono.CompilerServices.SymbolWriter.CodeBlockEntry.Type を非表示にする方法

概要 Mono.CompilerServices.SymbolWriter.CodeBlockEntry* Auto Import に上記の文字列を追加する

【Unity】Repaint を呼び出しても SceneTemplateAsset の Inspector の Dependencies が再描画されない場合

概要 var assembly = typeof( SceneTemplateAsset ).Assembly; var type = assembly.GetType( "UnityEditor.SceneTemplate.SceneTemplateAssetInspectorWindow" ); var rebuildDependenciesMethodInfo = type.GetMethod( "RebuildDependencies", BindingFlag…

【Rider】Path のコード補完から DG.Tweening.Plugins.Core.PathCore.Path を非表示にする方法

概要 DG.Tweening.Plugins.Core.PathCore* Auto Import に上記の文字列を追加する

【Rider】NotNull のコード補完から System.Diagnostics.CodeAnalysis.NotNullAttribute を非表示にする方法

概要 System.Diagnostics.CodeAnalysis.NotNullAttribute Auto Import に上記の文字列を追加する

【Unity】string.IsNullOrWhiteSpace を簡単に書けるようにするソーステンプレート

ソースコード [SourceTemplate] public static void isnullorwhitespace( this string self ) { /*$ string.IsNullOrWhiteSpace( str ) */ }

【Unity】string.IsNullOrEmpty を簡単に書けるようにするソーステンプレート

ソースコード [SourceTemplate] public static void isnullorempty( this string self ) { /*$ string.IsNullOrEmpty( str ) */ }

【Unity】コンポーネントの配列からすべてのゲームオブジェクトを削除する拡張メソッド

概要 public static void DestroyGameObjectAll<T>( this T[] self ) where T : Component { if ( self is not { Length: > 0 } ) return; for ( var i = 0; i < self.Length; i++ ) { var component = self[ i ]; Object.Destroy( component.gameObject ); sel</t>…

【Unity】指定された数分 Instantiate を実行する関数

概要 public static T[] Instantiates<T> ( T original, Transform parent, int count ) where T : Component { var array = new T[ count ]; original.gameObject.SetActive( true ); for ( var i = 0; i < count; i++ ) { var clone = Object.Instantiate( or</t>…

【Unity】DOTween の Rotate 系の拡張メソッドで X・Y・Z を個別指定できるようにする拡張メソッド

ソースコード using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using UnityEngine; namespace Kogane { public static class DOTweenRotateExtensionMethods { public static TweenerCore<Quaternion, Vector3, QuaternionOptions> DORotateX ( this Transform self,</quaternion,>…

【Unity】ゲームオブジェクトのアクティブを using で元に戻せるクラス

ソースコード using System; using UnityEngine; namespace Kogane { public sealed class GameObjectSetActiveScope : IDisposable { private readonly GameObject m_gameObject; private readonly bool m_oldIsActive; public GameObjectSetActiveScope ( …

【Unity】シーン開始時に子オブジェクトをすべて削除するコンポーネント

概要 using UnityEngine; namespace Kogane.Internal { /// <summary> /// シーン開始時に子オブジェクトをすべて削除するコンポーネント /// </summary> [DefaultExecutionOrder( -1000 )] [DisallowMultipleComponent] internal sealed class AutoDestroyChildrenComponent : …

【Unity】Mac の Unity エディタでも Windows のようなショートカットキーで Delete・Redo・Rename できるようにするエディタ拡張

ソースコード #if UNITY_EDITOR_OSX using System.Reflection; using UnityEditor; using UnityEditor.ShortcutManagement; using UnityEngine; namespace Kogane.Internal { /// <summary> /// Windows のようにショートカットキーを使用できるようにするエディタ拡</summary>…

【Unity】Mac で Unity から指定したアプリケーションでアセットを開く方法

概要 [MenuItem( "Tools/hoge" )] public static void Hoge() { var assetPath = "【アセットのパス】"; var fullPath = Path.GetFullPath( assetPath ); // Photoshop で開く例 Process.Start( @"open", $@"-a ""/Applications/Adobe Photoshop 2022/Adobe …

【Unity】Mac で Unity から別アプリケーションでアセットを開く方法

概要 [MenuItem( "Tools/hoge" )] public static void Hoge() { var assetPath = "【アセットのパス】"; var fullPath = Path.GetFullPath( assetPath ); Process.Start( @"open", fullPath ); }

【Unity】Mac で Unity から別のアプリケーションを終了する方法

概要 [MenuItem( "Tools/Hoge" )] public static void Hoge() { Process.Start( @"pkill", "Microsoft Power Point" ); }

【Unity】Importer(TextScriptImporter) generated inconsistent result for asset(guid:XXXX) "YYYY"

概要 File.Move(sourceFileName, destFileName); FileUtil.MoveFileOrDirectory( source, dest ); 上記の関数でアセットのファイル名を変更したら AssetDatabase.ImportAsset のタイミングで Importer(TextScriptImporter) generated inconsistent result fo…

【Unity】Assertion failed on expression: 'it != m_SendMap.end()'

概要 Unity の Project ウィンドウで画像を選択したら Unity エディタが強制終了する現象に遭遇した Assertion failed on expression: 'it != m_SendMap.end()' ================================================================= Native Crash Reporting …

【Unity】Mac で Unity Accelerator のダッシュボードの URL を確認する方法

概要 /Applications/Unity/accelerator/unity-accelerator dashboard url

【Python】python-pptx で 16:9 のスライドを作成する方法

概要 ppt = Presentation() ppt.slide_width = Inches(16) ppt.slide_height = Inches(9) 上記のように設定する 参考サイト様

【Python】AttributeError: module 'collections' has no attribute 'abc'

概要 AttributeError: module 'collections' has no attribute 'abc' python-pptx を使おうとしたら実行時に上記のエラーが発生する現象に遭遇した import collections.abc 上記の import 文を追加したらエラーが発生しなくなった 参考サイト様

【Python】Mac で python3 インストール後に「command not found: python」が出た時にやったこと

概要 /Users/【ユーザー名】/.zshrc 上記のファイルを開いて(存在しない場合は作成してから開いて) alias python='python3' 上記のコードを入力して保存したら python コマンドが実行できるようになった 参考サイト様

【Unity】軽量な DI フレームワーク「Reflex」

リンク

【Unity】Scripting Define Symbols にシンボルが定義されていない場合にのみ Assembly Definition を有効化する方法

概要 Define Constraints に入力するシンボルの先頭に ! をつけると そのシンボルが Scripting Define Symbols に定義されていない場合にのみ Assembly Definition が有効化されるようになります 参考サイト様

【Unity】EditorGUILayout のラベルの幅を設定する方法

概要 EditorGUIUtility.labelWidth = 64;