2019-11-28から1日間の記事一覧
概要 using UnityEngine; public class Example : MonoBehaviour { private void Awake() { var vec = new Vector3( 1.234f, 5.678f, 9.012f ); // (1.2, 5.7, 9.0) Debug.Log( vec.ToString() ); // (1.2340, 5.6780, 9.0120) Debug.Log( vec.ToString( "F4…
ソースコード using System; using System.Collections.Generic; public static class ListExt { public static bool TryFind<T>( this List<T> self, Predicate<T> match, out T result ) where T : class { result = self.Find( match ); return result != null; } </t></t></t>…
ソースコード using UnityEngine; public static class ComponentExt { public static bool TryGetComponentInParent<T>( this Component self, out T component ) where T : Component { component = self.GetComponentInParent<T>(); return component != null; </t></t>…
ソースコード using UnityEngine; public static class ComponentExt { public static bool TryGetComponentInChildren<T>( this Component self, out T component ) where T : Component { component = self.GetComponentInChildren<T>(); return component != nu</t></t>…
ソースコード using UnityEngine; public static class ComponentExt { public static bool TryGetComponent<T>( this Component self, out T component ) where T : Component { component = self.GetComponent<T>(); return component != null; } } public stati</t></t>…
概要 var collider = GetComponent<BoxCollider>(); if ( collider != null ) { Debug.Log( collider ); } GetComponent だとこのように記述する処理を if ( TryGetComponent<BoxCollider>( out var collider ) ) { Debug.Log( collider ); } TryGetComponent を使うとちょっとだけ簡潔</boxcollider></boxcollider>…
概要 Shortcut Manager でキー割り当てが変更された時に using UnityEditor; using UnityEditor.ShortcutManagement; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { ShortcutManager.instance.shortcutBindingCh…
はじめに 「UniColliderInterpolator」を Unity プロジェクトに導入することで non convex な Mesh Collider を綺麗に補間できます 使用例 通常 Mesh Collider の「Convex」をオンにすると このように凹凸の部分に正しく Mesh Collider が適用されません Uni…