2023-01-01から1年間の記事一覧
ソースコード /// <summary> /// アルファブレンドした色を返します /// </summary> public static Color AlphaBlend ( in Color backgroundColor, in Color overlapColor, float alpha ) { return backgroundColor + ( overlapColor - backgroundColor ) * alpha; } 使用例 var…
ソースコード using System.Linq; using TMPro; public static class TMP_TextExtensionMethods { public static float GetLocalEdgeLeft( this TMP_Text self ) { return self.transform.localPosition.x + self.textInfo.characterInfo.Min( x => x.bottom…
ソースコード using System.Linq; using TMPro; public static class TMP_TextExtensionMethods { public static float GetLocalEdgeLeft( this TMP_Text self ) { return self.transform.localPosition.x + self.textInfo.characterInfo.Min( x => x.bottom…
ソースコード using System; using System.Collections.Generic; public static class EnumerableExtensionMethods { public static IEnumerable<T> SkipWhileLast<T> ( this IEnumerable<T> self, Func<T, bool> predicate ) { var buffer = new List<T>(); var yieldStarted = f</t></t,></t></t></t>…
ソースコード using UnityEditor; using UnityEngine; using UnityEngine.UI; namespace Kogane.Internal { internal static class SetPreferredSizeMenuItem { [MenuItem( "CONTEXT/RectTransform/Set Preferred Size" )] private static void SetPreferred…
ソースコード using TMPro; using UnityEngine; namespace Kogane { public static class TMP_TextExtensionMethods { public static Vector3 GetCharacterPosition ( this TMP_Text self, int index ) { var characterInfo = self.textInfo.characterInfo[ …
ソースコード using TMPro; using UnityEngine; namespace Kogane { public static class TMP_TextExtensionMethods { public static Vector3 GetCharacterLocalPosition ( this TMP_Text self, int index ) { var characterInfo = self.textInfo.characterI…
ソースコード using System; using Kogane; using UnityEngine; public sealed class Example : MonoBehaviour { [SerializeField] private Collider2D m_collider2D; private bool m_isHit; public event Action<Collider2D> OnEnter; public event Action<Collider2D> OnExit; priv</collider2d></collider2d>…
ソースコード using UnityEngine; namespace Kogane { /// <summary> /// Bounds 型の拡張メソッド /// </summary> public static class BoundsExtensionMethods { //================================================================================ // 関数(static) //====…
ソースコード public float desiredSpeed = 5f; // 一定に保ちたい速度 private Rigidbody2D rb; private void Start() { rb = GetComponent<Rigidbody2D>(); } private void FixedUpdate() { Vector2 velocity = rb.velocity; float currentSpeed = velocity.magnitude; </rigidbody2d>…
ソースコード import os from pathlib import Path def normalize_audio_folder(folder_path): # フォルダ内のすべてのファイルとサブフォルダを再帰的に取得します for root, _, files in os.walk(folder_path): for file in files: if file.endswith(".mp3…
概要 public static void UpdatePositionsFromLineRenderer ( this LineRenderer self, LineRenderer lineRenderer ) { var positionCount = lineRenderer.positionCount; self.positionCount = positionCount; for ( var i = 0; i < positionCount; i++ ) {…
ソースコード using Unity.Collections; using Unity.Mathematics; using UnityEngine; using UnityEngine.Splines; namespace Kogane { public static class LineRendererExtensionMethods { public static void UpdateFromSplineContainer ( this LineRend…
ソースコード #if UNITY_EDITOR using System; using UnityEditor; using UnityEngine; namespace Kogane { [InitializeOnLoad] public static class ScreenSizeChecker { public static event Action OnChanged; static ScreenSizeChecker() { var oldWidth…
概要 { "name": "$NAME$" } Rider の Assembly Definition File のファイルテンプレートは上記のように 名前だけを保持する形式になっているので各種パラメータを保持する形式に変更した Rider の設定で「ファイル | 設定 | エディター | ファイルテンプレー…
概要 公式ドキュメントの上記のページに記載されています この記事では Rider の新しい UI での手順を書き残しておきます Rider の Unity のツールバーを右クリックして「ツールバーのカスタマイズ」を選択して 「+」を押して 「アクションの追加」を押して …
概要 Debug.Log( m_image.sprite.texture.width ); Debug.Log( m_image.sprite.texture.height );
概要 private void LateUpdate() { var x = Mathf.LerpUnclamped( m_minX, m_maxX, m_scrollRect.horizontalNormalizedPosition ); // ... } LateUpdate で ScrollRect.horizontalNormalizedPosition を参照して ゲームオブジェクトの X 座標を設定しようと…
ソースコード using System.Collections.Generic; using DG.Tweening; using Unity.Collections; using UnityEngine; namespace Kogane { /// <summary> /// LineRenderer 型の DOTween 関連の拡張メソッド /// </summary> public static class DOTweenLineRendererExtensionMet…
概要 JetBrains Rider を 2023.1.1 にアップデートしたら フィールド名を変更した時に FormerlySerializedAs が自動で付与されるようになった Preferences を開いて「言語 & フレームワーク > Unity エンジン」の 「シリアル化されたフィールドの名前を変更…
概要 import glob import librosa import soundfile import shutil import sys import os # コマンドライン引数で指定されたディレクトリに存在するすべての .ogg のファイルパスを取得 files = glob.glob(sys.argv[1] + "/*.ogg") for file in files: # .og…
概要 find . -name "*.wav" -type f -maxdepth 3 | while read -r waveFile do oggFile=${waveFile%.wav}.ogg ffmpeg -nostdin -y -i "${waveFile}" -vn -ac 2 -ar 44100 -ab 128k -acodec libvorbis -f ogg "${oggFile}" done ffmpeg を使用して複数の音声…
概要 一 二 三 四 五 六 七 八 九 十 十一 十二 十三 十四 十五 十六 十七 十八 十九 二十 二十一 二十二 二十三 二十四 二十五 二十六 二十七 二十八 二十九 三十 三十一 三十二 三十三 三十四 三十五 三十六 三十七 三十八 三十九 四十 四十一 四十二 四十…
概要 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 …
概要 System.Text.Json などを使用せずに パラメータ名にハイフンを含む Json を JsonUtility で読み込みたい場合 json = json.Replace( "\"time-offset\"", "\"time_offset\"" ); 一応、上記のようにパラメータ名を置換すれば読み込める 参考サイト様
概要 システム環境設定の「キーボード > サービス」を選択して 「ターミナルのm...デックスで検索」をオフにする
概要 Consider updating External Editor in Unity to Rider 2023.1. JetBrains Rider を 2023.1 にアップデートしたら Unity で上記の警告が出力された Package Manager で「JetBrains Rider Editor」をアップデートしたら出力されなくなった
ソースコード using System.IO; using UnityEngine; namespace Kogane { public static class ScreenCapture { public static void CaptureScreenshot ( string path, Camera camera = null, bool isTransparent = true ) { if ( camera == null ) { camera …
概要 var type = typeof( EditorWindow ).Assembly.GetType( "UnityEditor.GameView" ); EditorWindow.FocusWindowIfItsOpen( type );
ソースコード using UnityEditor; using UnityEngine; namespace Kogane.Internal { internal static class CopyBatchModeScriptTemplateMenuItem { [MenuItem( "Kogane/バッチモードでビルドするシェルスクリプトのテンプレートをコピー" )] private static…