コガネブログ

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

2022-08-25から1日間の記事一覧

【Rider】新規ファイル追加時に git add しないようにする方法

概要 Preferences の「Version Control > Confirmation」の 「When files are created」を「Do not add」にする 参考サイト様

【Unity】VisualElement でボタンを末尾ではなく先頭に追加する方法

概要 visualElement.Insert( 0, pingButton ); Add ではなく Insert を使う

【C#】指定した値が組み込みの値型かどうかを確認する方法

C#

概要 // すべて True Debug.Log( typeof( bool ).IsValueType ); Debug.Log( typeof( byte ).IsValueType ); Debug.Log( typeof( sbyte ).IsValueType ); Debug.Log( typeof( char ).IsValueType ); Debug.Log( typeof( decimal ).IsValueType ); Debug.Log(…

【C#】指定した値が配列かどうかを確認する方法

C#

概要 var array1 = new int[ 0 ]; var array2 = new string[ 0 ]; var array3 = new Vector3[ 0 ]; Debug.Log( array1.GetType().IsArray ); Debug.Log( array2.GetType().IsArray ); Debug.Log( array3.GetType().IsArray ); 参考サイト様

【C#】指定した値が Dictionary かどうかを確認する方法

C#

概要 var dictionary1 = new Dictionary<int, string>(); var dictionary2 = new Dictionary<int, Vector3>(); Debug.Log( typeof( Dictionary<,> ).IsAssignableFrom( dictionary1.GetType().GetGenericTypeDefinition() ) ); Debug.Log( typeof( Dictionary<,> ).IsAssignableFrom( di</int,></int,>…

【C#】指定した値が List かどうかを確認する方法

C#

概要 参考サイト様

【Unity】The target object is null. Check for missing scripts.

概要 The target object is null. Check for missing scripts. Unity エディタで上記のエラーが発生する場合は 削除されたスクリプトを参照しているゲームオブジェクトが シーンに存在する可能性があります 「Missing」になっているスクリプトを右クリックし…

【Unity】SendMessage cannot be called during Awake, CheckConsistency, or OnValidate (XXXX: OnRectTransformDimensionsChange)

はじめに using UnityEngine; public class Example : MonoBehaviour { private void OnValidate() { Apply(); } private void Apply() { var rectTransform = GetComponent<RectTransform>(); rectTransform.sizeDelta = new Vector2 ( Random.Range( 0f, 100f ), Random.R</recttransform>…

【Rider】閉じたタブを開く方法

概要 Preferences の「Keymap」で「Main Menu > Window > Editor Tabs > Reopen Closed Tab」に ショートカットキーを割り当てると即座に閉じたタブを開けるようになる 参考サイト様

【Unity】UI の Image では Material Property Block は使用できない

参考サイト様

【Unity】Package Manager の Install・Remove ボタンの隣にボタンを表示するサンプル

ソースコード using System; using System.Collections.Generic; using System.IO; using System.Reflection; using UnityEditor; using UnityEditor.PackageManager.UI; using UnityEditorInternal; using UnityEngine.UIElements; using PackageInfo = Uni…

【Rider】選択中のテキストのバックグラウンドカラーを変更する方法

概要 Preferences の「Editor > Color Scheme > General」の 「Editor > Selection background」の「Background」の色を変更する

【Rider】Mac で Preferences のカラーピッカーが正常に動作しない場合

概要 「システム環境設定 > セキュリティとプライバシー > 画面収録」で 「Rider.app」のチェックを外したら正常に動作するようになった

【Unity】Zenn の Unity に関するフィードを購読する方法

概要 https://zenn.dev/topics/unity/feed 上記の URL を RSS リーダに追加する

【Unity】Device Simulator に Mute Audio ボタンを追加するエディタ拡張

ソースコード using JetBrains.Annotations; using UnityEditor; using UnityEditor.DeviceSimulation; using UnityEngine.UIElements; namespace Kogane.Internal { [UsedImplicitly] internal sealed class DeviceSimulatorMuteAudioPlugin : DeviceSimula…