using System.Collections; using System.Collections.Generic; using UnityEngine; #if UNITY_EDITOR using UnityEditor; #endif /// /// this class is for logic test. /// if you build with this class, this class must be nothing to do. /// public class LogicTest : MonoBehaviour { #if UNITY_EDITOR [SerializeField] int testCount = 1; [ContextMenu("Method/LogicTest")] public void SwapElementsTest() { int currentTestCount = 0; while(currentTestCount++ < testCount) { List list = new List(); int rndSize = Random.Range(1, 10); for (int i = 0; i < rndSize; ++i) { list.Add(Random.Range(0, 100)); } string beforeSort = "Before swap : "; for (int i = 0; i < list.Count; ++i) { beforeSort += list[i] + " "; } Logger.Log(beforeSort); int result = list.SwapElements((e) => e > 50); string afterSort = "After swap : "; for (int i = 0; i < list.Count; ++i) { afterSort += list[i] + " "; } Logger.Log(afterSort); Logger.Log("Result : " + result); } } #endif }