コガネブログ

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

2022-09-16から1日間の記事一覧

【Unity】コンポーネントの配列からすべてのゲームオブジェクトを削除する拡張メソッド

概要 public static void DestroyGameObjectAll<T>( this T[] self ) where T : Component { if ( self is not { Length: > 0 } ) return; for ( var i = 0; i < self.Length; i++ ) { var component = self[ i ]; Object.Destroy( component.gameObject ); sel</t>…

【Unity】指定された数分 Instantiate を実行する関数

概要 public static T[] Instantiates<T> ( T original, Transform parent, int count ) where T : Component { var array = new T[ count ]; original.gameObject.SetActive( true ); for ( var i = 0; i < count; i++ ) { var clone = Object.Instantiate( or</t>…

【Unity】DOTween の Rotate 系の拡張メソッドで X・Y・Z を個別指定できるようにする拡張メソッド

ソースコード 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,>…