2022-09-01から1ヶ月間の記事一覧
概要 System.Numerics* Auto Import に上記の文字列を追加する
はじめに 「DragAndDropFromField」を Unity プロジェクトに導入することで ObjectField からドラッグできるようになります 導入後
概要 using System.Threading; using UnityEngine; public class Example : MonoBehaviour { private void Awake() { Debug.Log( CancellationToken.None == default ); // True } }
ソースコード using System; using System.Collections.Generic; namespace Kogane { // ReSharper disable once InconsistentNaming public static class IEnumerableExtensionMethods { public static bool TryElementAt<TSource> ( this IEnumerable<TSource> source, int i</tsource></tsource>…
ソースコード using System; using UnityEditor; namespace Kogane.Internal { [InitializeOnLoad] internal static class AutoFocusGameViewOnPlayModeStateChanged { private static readonly Type GAME_VIEW_TYPE; static AutoFocusGameViewOnPlayModeSta…
はじめに 「Unity-2021-with-old-toolbar」を Unity プロジェクトに導入することで Unity 2021 から削除された古いツールバーが使えるようになります 導入後
概要 UnityEngine.Windows* Auto Import に上記の文字列を追加する
概要 UnityEngine.Windows.Directory Auto Import に上記の文字列を追加する
概要 System.Net.WebRequestMethods* UnityEngine.Windows.File Auto Import に上記の文字列を追加する
概要 MG.GIF.Image Auto Import に上記の文字列を追加する
概要 Auto Import の一覧に以下の 2 つを追加する UnityEngine.ADBannerView* UnityEngine.iOS.ADBannerView*
ソースコード using System; namespace Kogane { public static class TypeUtils { public static string GetCSharpTypeKeyword( Type type ) { return GetCSharpTypeKeyword( type.Name ); } // https://stackoverflow.com/questions/56352299/gettype-retu…
ソースコード using System; using System.Linq; namespace Kogane { public static class TypeUtils { // https://stackoverflow.com/questions/1533115/get-generictype-name-in-good-format-using-reflection-on-c-sharp public static string GetPrettyN…
概要 Rider の Preferences の「Editor > Live Templates > C#」を選択して 「New Template」のアイコンを押して 「Shortcut:」に summaryComment と入力して左のテキストエリアに /// <summary> /// $END$ /// </summary> と入力して保存する 設定
ソースコード using System; using System.Reflection; using UnityEditor; namespace Kogane.Internal { public static class PropertyEditorInternal { private const BindingFlags BINDING_ATTRS = BindingFlags.Instance | BindingFlags.NonPublic; priv…
概要 Before After 重ねた場合 備考 上記のシェーダは以下の公式フォーラムで投稿されていたものになります
ソースコード #if UNITY_EDITOR using System; using System.Collections.Generic; using JetBrains.Annotations; // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming namespace Kogane { [PublicAPI] [Obsolete( "", true )] pu…
スライド
概要 備考 上記のシェーダは以下の公式フォーラムで投稿されていたものになります
ソースコード using UnityEngine; namespace Kogane { public static class DebugLogMethodChainingExtensionMethods { public delegate void LogDelegate( object item ); public static LogDelegate OnLog { get; set; } = item => Debug.Log( item ); pub…
ソースコード #if UNITY_EDITOR using System; using JetBrains.Annotations; // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming namespace Kogane { [PublicAPI] [Obsolete( "", true )] public static class SourceTemplateCo…
ソースコード namespace Kogane { public static class StringExtensionMethods { public static bool IsAlphanumeric( this string self ) { for ( var i = 0; i < self.Length; i++ ) { var x = self[ i ]; if ( !char.IsLetterOrDigit( x ) ) { return fa…
ソースコード namespace Kogane { public static class CharExtensionMethods { public static bool IsAlphanumeric( this char self ) { return char.IsLetterOrDigit( self ); } } } 使用例 Debug.Log( '0'.IsAlphanumeric() ); // True Debug.Log( 'A'.Is…
概要 var isAlphanumeric = char.IsLetterOrDigit( 'A' ); // True char.IsLetterOrDigit を使うと判定できる 0 ~ 9、A ~ Z、a ~ z は True になる 記号や半角スペースは False になる 使用例 // 0 ~ 9、A ~ Z、a ~ z は True になる var isAlphanumeric = "…
概要 「GameObject」メニューにゲームオブジェクトを作成するメニューを追加する場合、 「GameObjectUtility.SetParentAndAlign」を必ず呼び出し、 親を設定し、子に同じレイヤーと位置を与えます。 また、「Undo.RegisterCreatedObjectUndo」を呼び出して作…
ソースコード using System; using System.Collections.Generic; using JetBrains.Annotations; namespace Kogane { public static class IEnumerablePeekExtensionMethods { public static IEnumerable<T> Peek<T> ( [NotNull] this IEnumerable<T> source, [NotNull</t></t></t>…
概要 xcopy /e /s /y ^ "【Unity プロジェクト A のパス】\Packages\*" ^ "【Unity プロジェクト B のパス】\Packages"
ソースコード using System; using System.Collections.Generic; using JetBrains.Annotations; using UnityEngine; namespace Kogane { public static class IEnumerableLogExtensionMethods { public delegate void LogDelegate( object item ); public st…
概要 var fullPath = Path.GetFullPath( assetPath ).Replace( "\\", "/" ); var currentDirectory = Directory.GetCurrentDirectory(); var relativePath = Path.GetRelativePath( currentDirectory, fullPath ).Replace( "\\", "/" ); var isPackageCache …
概要 private static string ToLiteralString( object value ) { if ( value == null ) return "null"; if ( value is bool boolValue ) return boolValue ? "true" : "false"; if ( value is float floatValue ) return $"{floatValue}f"; if ( value is lo…