using System.Text; using UnityEngine; namespace BitStrap.Examples { public class CircularBufferExample : MonoBehaviour { [Header("Edit the fields and click the buttons to test them!")] public int value = 10; private CircularBuffer buffer = new CircularBuffer(4); [Button] public void Add() { if (!Application.isPlaying) { Debug.LogWarning("In order to see CircularBuffer working, please enter Play mode."); return; } buffer.Add(value++); Print(); } [Button] public void Print() { if (!Application.isPlaying) { Debug.LogWarning("In order to see CircularBuffer working, please enter Play mode."); return; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < buffer.Count; i++) { stringBuilder.Append(buffer[i]); stringBuilder.Append(", "); } Debug.Log(stringBuilder); } } }