2021-01-01から1年間の記事一覧
概要 using UnityEditor; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var gameObject = Selection.activeGameObject; var lineRenderer = gameObject.GetComponent<LineRenderer>(); lineRenderer.materi</linerenderer>…
ソースコード using UnityEngine; [DisallowMultipleComponent] [ExecuteAlways] [RequireComponent( typeof( SpringJoint2D ) )] [RequireComponent( typeof( LineRenderer ) )] public sealed class Example : MonoBehaviour { private SpringJoint2D m_sp…
概要 var mat = AssetDatabase.GetBuiltinExtraResource<Material>( "Sprites-Default.mat" ); 上記のコードを書くとエディタ拡張で Sprites-Default マテリアルを使用できます</material>
概要 Rider の設定の「キーマップ」の「挿入/上書きの切り替え」を右クリックして 「Insert の除去」を押してから「Save」を押すと Insert キーを押した時に上書きモードにならなくなります
概要 Unity で「Suppress Common Warnings」をオンにすれば Unity 上では 0169 と 0649 の警告は出なくなるが Rider 上でビルドした場合は警告が出るので以下のエディタ拡張を作って警告を抑制 using System.IO; using System.Text; using System.Xml.Linq; …
はじめに 「NormalView」を Unity プロジェクトに導入することで Scene ビューに 3D オブジェクトの法線・接線・従法線を表示できるようになります 使用例 クイックスタート 3D オブジェクトに Normal View をアタッチすることで表示できます
はじめに 「UnityTextureFormatCheckerKun」を Unity プロジェクトに導入することで デバイスが対応している Texture フォーマットを確認できるようになります
概要 using Cysharp.Threading.Tasks; using UnityEditor; using UnityEditor.Experimental.SceneManagement; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { PrefabStage.prefabStageOpened += async stage => {…
概要 using UnityEditor; using UnityEngine; public static class Example { [MenuItem( "Tools/FixCameraPivotAndSize" )] public static void FixCameraPivotAndSize() { var sceneView = SceneView.lastActiveSceneView; if ( sceneView == null ) retur…
概要 Rider の設定の「エディター > 一般 > 外観」の「空白を表示」をオンにすると 空白を表示できます
概要 namespace と入力した時に MyNamespace 以外の名前が入力されるようにしたい場合、 Rider の設定の「エディター > Live Templates > C#」を押して 「namespace」の「Edit variables」を押して 好きな名前を入力して「Done」を押して「Save」を押します …
概要 コンポーネントの Inspector に表示される「Script」の欄を非表示にしたい場合は using Sirenix.OdinInspector; using UnityEngine; [HideMonoScript] public class Example : MonoBehaviour { public string m_name; } HideMonoScript をクラスに付け…
ソースコード using UnityEditor; using UnityEditor.SceneManagement; [InitializeOnLoad] public static class Example { static Example() { EditorApplication.playModeStateChanged += change => { if ( change != PlayModeStateChange.ExitingEditMode…
ソースコード using UnityEditor; using UnityEditor.SceneManagement; public static class Example { [MenuItem( "Tools/Hoge" )] public static void Hoge() { StageUtility.GoToMainStage(); } }
概要 Rider で宣言に移動するとデフォルトでは 関数の中身などがデコンパイルされた状態で表示されますが Rider の設定の「ツール > External Symbols」を開いて 「Decompile methods」をオフにして保存すると 宣言に移動した時に関数の中身などがデコンパイ…
概要 Rider メニューの「コード > 折りたたみ > Doc コメントを折りたたむ」を選択すると XML ドキュメントコメントをすべて折りたたむことができる 参考サイト様
概要 The class named 'XXXX' is not derived from MonoBehaviour or ScriptableObject! Console ウィンドウにこのような警告メッセージが表示される場合は シーンに存在するゲームオブジェクトに MonoBehaviour を継承していないクラスのスクリプトがアタッ…
概要 GameObject (named 'XXXX') references runtime script in scene file. Fixing! Console ウィンドウにこのような警告メッセージが表示される場合は シーンに存在するゲームオブジェクトに MonoBehaviour を継承していないクラスのスクリプトがアタッチ…
概要 'XXXX' is missing the class attribute 'ExtensionOfNativeClass'! Console ウィンドウにこのようなエラーメッセージが表示される場合は シーンに存在するゲームオブジェクトに MonoBehaviour を継承していないクラスのスクリプトがアタッチされている…
概要 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…
概要 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…
はじめに 「DeltaTimeChecker」を Unity プロジェクトに導入することで Time.deltaTime をグラフで可視化できるようになります 使用例 クイックスタート 空のゲームオブジェクトに「Time Graph」をアタッチして Texture に rect.png を設定することで使用で…
概要 タイルマップの各タイルの当たり判定を結合したい場合は Tilemap Collider 2D を保持しているゲームオブジェクトに 「Rigidbody 2D」と「Composite Collider 2D」を Add Component して Rigidbody 2D の「Body Type」を「Dynamic」以外にして Tilemap C…
概要 TerrainTile は通常は当たり判定がスプライト状になりますが tileData.colliderType = Tile.ColliderType.Sprite; TerrainTile.cs 75 行目の上記の処理を tileData.colliderType = Tile.ColliderType.Grid; このように書き換えることで 当たり判定をグ…
はじめに 「AndroidManifestReflection」を Unity プロジェクトに導入することで AndroidManifest をコードから編集できるようになります 使用例 using UnityEditor; using UTJ.Android.Extensions; internal static class Example { [MenuItem( "Tools/Hoge…
概要 Rider にログインしている状態で Rider 右下の雲のアイコンを押して「同期を有効にする...」を押します 必要に応じてチェックボックスをオンにして「設定の同期を有効にする」を押します しばらく待機して「IDE 設定が同期されました」と表示されたら …
ソースコード using UnityEditor; using UnityEngine; using UnityEngine.Tilemaps; [InitializeOnLoad] internal static class Example { static Example() { EditorApplication.playModeStateChanged += change => { if ( change != PlayModeStateChange.E…
概要 Shaper 2D の「Auto collider 2D」を「Polygon」に変更すると 図形に合わせてコライダを適用できる
概要 「Selected Lines Count」を VS Code に導入することで 選択中の行数を表示できるようになります 使用例
はじめに 「UnityProfilerLiteKun」は メモリが許す限り Profile を記録できる簡易プロファイラです 使用例 クイックスタート Unity メニューの「Window > UTJ > UnityProfilerLiteKun」を押して 通常の Profile と同様にビルドしたプレイヤーに接続して レ…