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 PLATFORM_ANDROID AndroidJavaObject pluginInstance; private void Start() { #if false if(AndroidJava.InitPluginInstance("com.goodcirclegames.unityplugintest", out pluginInstance)) { Debug.Log("init success, toast repeating"); InvokeRepeating(nameof(Toast), 1.0f, 3.0f); } #endif } public void Toast() { if (pluginInstance is null) return; Debug.Log("call Toast"); pluginInstance.Call("Toast", "Say hello from unity!"); } #endif #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); } } private void OnTriggerEnter2D(Collider2D collision) { Logger.Log("OnTriggerEnter2D : " + collision.gameObject.name); } #endif }