コガネブログ

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

2022-10-14から1日間の記事一覧

【C#】配列やリストの要素がすべて同じかどうか確認する方法

C#

概要 using System.Linq; using UnityEngine; public class Example : MonoBehaviour { private void Awake() { var list1 = new[] { 1, 2, 3 }; var list2 = new[] { 1, 1, 1 }; Debug.Log( list1.Distinct().Count() == 1 ); // False Debug.Log( list2.Di…

【Unity】MenuItem でも Event.current を取得できる関数

ソースコード private static Event GetEventCurrent() { var fieldInfo = typeof( Event ).GetField ( name: "s_Current", bindingAttr: BindingFlags.Static | BindingFlags.NonPublic ); return ( Event )fieldInfo.GetValue( null ); } 参考サイト様