コガネブログ

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

2021-11-10から1日間の記事一覧

【Unity】プレハブモードになった時に Scene ビューの 2D カメラの位置やサイズを変更するエディタ拡張

概要 using Cysharp.Threading.Tasks; using UnityEditor; using UnityEditor.Experimental.SceneManagement; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { PrefabStage.prefabStageOpened += async stage => {…

【Unity】Scene ビューの 2D カメラの位置やサイズを変更するエディタ拡張

概要 using UnityEditor; using UnityEngine; public static class Example { [MenuItem( "Tools/FixCameraPivotAndSize" )] public static void FixCameraPivotAndSize() { var sceneView = SceneView.lastActiveSceneView; if ( sceneView == null ) retur…

【Rider】空白を表示する方法

概要 Rider の設定の「エディター > 一般 > 外観」の「空白を表示」をオンにすると 空白を表示できます

【Rider】namespace と入力した時に MyNamespace 以外の名前が自動で入力されるようにする方法

概要 namespace と入力した時に MyNamespace 以外の名前が入力されるようにしたい場合、 Rider の設定の「エディター > Live Templates > C#」を押して 「namespace」の「Edit variables」を押して 好きな名前を入力して「Done」を押して「Save」を押します …

【Unity】Odin で Inspector の Script の欄を非表示にする方法

概要 コンポーネントの Inspector に表示される「Script」の欄を非表示にしたい場合は using Sirenix.OdinInspector; using UnityEngine; [HideMonoScript] public class Example : MonoBehaviour { public string m_name; } HideMonoScript をクラスに付け…

【Unity】Unity を再生する時にプレハブモードを終了するエディタ拡張

ソースコード using UnityEditor; using UnityEditor.SceneManagement; [InitializeOnLoad] public static class Example { static Example() { EditorApplication.playModeStateChanged += change => { if ( change != PlayModeStateChange.ExitingEditMode…

【Unity】プレハブモードを終了するエディタ拡張

ソースコード using UnityEditor; using UnityEditor.SceneManagement; public static class Example { [MenuItem( "Tools/Hoge" )] public static void Hoge() { StageUtility.GoToMainStage(); } }

【Rider】宣言に移動した時にデコンパイルしないようにする方法

概要 Rider で宣言に移動するとデフォルトでは 関数の中身などがデコンパイルされた状態で表示されますが Rider の設定の「ツール > External Symbols」を開いて 「Decompile methods」をオフにして保存すると 宣言に移動した時に関数の中身などがデコンパイ…

【Rider】XML ドキュメントコメントをすべて折りたたむ方法

概要 Rider メニューの「コード > 折りたたみ > Doc コメントを折りたたむ」を選択すると XML ドキュメントコメントをすべて折りたたむことができる 参考サイト様

【Unity】The class named 'XXXX' is not derived from MonoBehaviour or ScriptableObject!

概要 The class named 'XXXX' is not derived from MonoBehaviour or ScriptableObject! Console ウィンドウにこのような警告メッセージが表示される場合は シーンに存在するゲームオブジェクトに MonoBehaviour を継承していないクラスのスクリプトがアタッ…

【Unity】GameObject (named 'XXXX') references runtime script in scene file. Fixing!

概要 GameObject (named 'XXXX') references runtime script in scene file. Fixing! Console ウィンドウにこのような警告メッセージが表示される場合は シーンに存在するゲームオブジェクトに MonoBehaviour を継承していないクラスのスクリプトがアタッチ…

【Unity】'XXXX' is missing the class attribute 'ExtensionOfNativeClass'!

概要 'XXXX' is missing the class attribute 'ExtensionOfNativeClass'! Console ウィンドウにこのようなエラーメッセージが表示される場合は シーンに存在するゲームオブジェクトに MonoBehaviour を継承していないクラスのスクリプトがアタッチされている…

【Unity】You are trying to replace or create a Prefab from the instance 'XXXX' that contains the script 'YYYY', which does not derive from MonoBehaviour. This is not allowed.

概要 Saving failed. Check the Console window to get more insight into what needs to be fixed. プレハブを編集して保存する時に上記のエラーダイアログが表示されて You are trying to replace or create a Prefab from the instance 'XXXX' that conta…

【Unity】You are trying to replace or create a Prefab from the instance 'XXXX' that references a missing script. This is not allowed.

概要 Saving failed. Check the Console window to get more insight into what needs to be fixed. プレハブを編集して保存する時に上記のエラーダイアログが表示されて You are trying to replace or create a Prefab from the instance 'XXXX' that refer…

【Unity】Time.deltaTime をグラフで可視化できる「DeltaTimeChecker」紹介

はじめに 「DeltaTimeChecker」を Unity プロジェクトに導入することで Time.deltaTime をグラフで可視化できるようになります 使用例 クイックスタート 空のゲームオブジェクトに「Time Graph」をアタッチして Texture に rect.png を設定することで使用で…