概要
「StackList」を Unity プロジェクトに導入することで
GC Alloc が発生しない Stack を使用できるようになります
使用例
using Hont; using System.Collections.Generic; using UnityEngine; using UnityEngine.Profiling; public class Example : MonoBehaviour { private void Update() { Profiler.BeginSample( "# StackList" ); var stackList = new StackList<Vector3>(); stackList.Add( new Vector3( 1, 0, 0 ) ); stackList.Add( new Vector3( 2, 0, 0 ) ); stackList.Add( new Vector3( 3, 0, 0 ) ); stackList.Add( new Vector3( 4, 0, 0 ) ); Profiler.EndSample(); Profiler.BeginSample( "# Stack" ); var stack = new Stack<Vector3>(); stack.Push( new Vector3( 1, 0, 0 ) ); stack.Push( new Vector3( 2, 0, 0 ) ); stack.Push( new Vector3( 3, 0, 0 ) ); stack.Push( new Vector3( 4, 0, 0 ) ); Profiler.EndSample(); } }