ソースコード using System.Collections.Generic; using DG.Tweening; using Unity.Collections; using UnityEngine; namespace Kogane { /// <summary> /// LineRenderer 型の DOTween 関連の拡張メソッド /// </summary> public static class DOTweenLineRendererExtensionMet…
ソースコード using TMPro; namespace Kogane { // ReSharper disable once InconsistentNaming public static class TMP_TextTextIdExtensionMethods { public static void SetText ( this TMP_Text self, TextId textId ) { self.text = textId.Value; } p…
ソースコード using TMPro; using UnityEngine; using UnityEngine.UI; namespace Kogane { public static class GraphicExtensionMethods { public static void SetColorIfNotNull( this Graphic self, in Color color ) { if ( self == null ) return; sel…
ソースコード using System; using Cysharp.Threading.Tasks; namespace Kogane { public static class FuncUniTaskExtensionMethods { public static async UniTask Call( this Func<UniTask> self ) { if ( self != null ) { await self(); } } } }</unitask>
ソースコード using System.Collections.Generic; using UnityEngine; namespace Kogane { public static class AnimatorExtensionMethods { public static void Play( this Animator self ) { self.Play( 0 ); } public static void Play( this IReadOnlyLi…
リポジトリ 使用例 // protected な Save 関数を public で呼び出せるようにする拡張メソッド scriptableSingleton.Save( true );
はじめに 「com.bovinelabs.core」を Unity プロジェクトに導入することで NativeList や NativeArray の拡張メソッドが使えるようになります NativeList の拡張メソッド https://gitlab.com/tertle/com.bovinelabs.core/-/blob/master/BovineLabs.Core/Exte…
リポジトリ 使用例 using Kogane; using UnityEngine; public sealed class Example : MonoBehaviour { public GameObject m_prefab; private void Awake() { var r1 = m_prefab.Instantiate(); var r2 = m_prefab.Instantiate( Vector3.zero ); var r3 = m_…
ソースコード using Unity.Collections; namespace Kogane { public static class NativeArrayExtensionMethods { public static void Reverse<T>( this NativeArray<T> self ) where T : unmanaged { var halfLength = self.Length / 2; var i = 0; var j = self.</t></t>…
ソースコード using Unity.Collections; namespace Kogane { public static class NativeListExtensionMethods { public static void Reverse<T>( this NativeList<T> self ) where T : unmanaged { var halfLength = self.Length / 2; var i = 0; var j = self.Le</t></t>…
リポジトリ 使用例 using System.Threading; using Cysharp.Threading.Tasks; using Kogane; using UnityEngine; public class Example : MonoBehaviour { private readonly CancellationTokenSource m_cancellationTokenSource = new(); private async UniT…
概要 「Editor-View-TransformChanged helper」を Unity プロジェクトに導入することで Transform が変化したことを検知できるようになります 使い方 using Needle.TransformExtensions; using UnityEngine; public class Example : MonoBehaviour { private…
リポジトリ 使用例 Before using System; using System.Collections.Generic; using Cysharp.Threading.Tasks; using UnityEngine; public class Example : MonoBehaviour { private async UniTaskVoid Start() { var list = new List<UniTask>(); for ( var i = 0; i </unitask>…
リポジトリ 使用例 using Cysharp.Threading.Tasks; using Kogane; using UnityEngine; public sealed class Example : MonoBehaviour { private async UniTaskVoid Star() { UniTask Impl1() => UniTask.CompletedTask; UniTask<bool> Impl2() => UniTask.FromRes</bool>…
リポジトリ 使用例 using Kogane; using UnityEngine; using UnityEngine.EventSystems; public sealed class Example : MonoBehaviour, IPointerClickHandler { void IPointerClickHandler.OnPointerClick( PointerEventData eventData ) { // シングルタッ…
リポジトリ 使用例 using Kogane; using UnityEngine; public class Example : MonoBehaviour { private void Start() { var transform = gameObject.GetComponentInChildren( "Transform" ); var transforms = gameObject.GetComponentsInChildren( "Transf…
ソースコード using UnityEngine; namespace Kogane { public static class CameraExtensionMethods { public static Vector2 ScreenToWorldPoint2D ( this Camera self, Vector3 position ) { return self.ScreenToWorldPoint( position ); } public static…
ソースコード using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using UnityEngine; namespace Kogane { public static class DOTweenRotateExtensionMethods { public static TweenerCore<Quaternion, Vector3, QuaternionOptions> DORotateX ( this Transform self,</quaternion,>…
ソースコード 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…
ソースコード 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>…
ソースコード 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…
ソースコード using DG.Tweening; namespace Kogane { public static class TweenExtensionMethods { public static Tween Append( this Tween self, Sequence sequence ) { sequence.Append( self ); return self; } public static Tween Insert( this Twee…
ソースコード using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using UnityEngine; namespace Kogane { public static class DOTweenTransformShortcutExtensionMethods { public static TweenerCore<Vector3, Vector3, VectorOptions> DOMove ( this GameObj</vector3,>…
ソースコード using UnityEngine; public static class UnityEngineObjectExtensions { public static T Clone<T>( this T self ) where T : Component { return Object.Instantiate( self ); } public static T CloneInParent<T>( this T self ) where T : Compon</t></t>…
ソースコード using UnityEngine; using UnityEngine.Tilemaps; public static class TilemapExtensions { public static void SetTile ( this Tilemap self, int x, int y, TileBase tile ) { self.SetTile( new Vector3Int( x, y, 0 ), tile ); } public s…
ソースコード using System.Collections.Generic; using UnityEngine; using UnityEngine.Tilemaps; public static class TilemapExtensions { public static IEnumerable<Vector3Int> GetPositions( this Tilemap self ) { var bound = self.cellBounds; for ( var x = </vector3int>…
ソースコード 使用例 using UniRx.Async; using UnityEngine; public sealed class Example : MonoBehaviour { private async void Start() { #if ENABLE_RELEASE #else UniTaskExt.OnStartLog += message => Debug.Log( $"{message} 開始" ); UniTaskExt.On…
ソースコード 使用例 using System; using UnityEngine; public class Character : IDisposable { public void Dispose() { Debug.Log( "ピカチュウ" ); } } public class Example : MonoBehaviour { private void Start() { var character = new Character(…
概要 BuildPipeline.GetBuildTargetGroup を使用する もしくは下記のような拡張メソッドを自作する using UnityEditor; public static class BuildTargetExt { public static BuildTargetGroup ToBuildTargetGroup( this BuildTarget self ) { switch ( self…
はじめに 「RichText for Unity」を Unity プロジェクトに導入することで メソッドチェーンでリッチテキストを設定できるようになります 使用例 var str = "ピカチュウ"; // 通常 Debug.Log( $"<color=purple><size=17><b><i>{str}</i></b></size></color>"); // RichText for Unity Debug.Log( $"{str.Italic().B…