2021-04-04 03:41:36 +10:00
|
|
|
|
using System;
|
2021-05-03 21:02:01 +10:00
|
|
|
|
using System.Collections;
|
2021-04-04 03:41:36 +10:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2021-05-03 21:02:01 +10:00
|
|
|
|
using UnityEngine;
|
2021-04-04 03:41:36 +10:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
namespace UnityExplorer.Tests
|
2021-04-04 03:41:36 +10:00
|
|
|
|
{
|
|
|
|
|
public static class TestClass
|
|
|
|
|
{
|
2021-05-03 21:02:01 +10:00
|
|
|
|
public static IEnumerable ANestedList = new List<List<List<string>>>
|
|
|
|
|
{
|
|
|
|
|
new List<List<string>>
|
|
|
|
|
{
|
|
|
|
|
new List<string>
|
|
|
|
|
{
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
"one",
|
|
|
|
|
"two",
|
|
|
|
|
},
|
|
|
|
|
new List<string>
|
|
|
|
|
{
|
|
|
|
|
"three",
|
|
|
|
|
"four",
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new List<List<string>>
|
|
|
|
|
{
|
|
|
|
|
new List<string>
|
|
|
|
|
{
|
|
|
|
|
"five"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static IDictionary DictTest = new Dictionary<object, object>
|
|
|
|
|
{
|
|
|
|
|
{ 1, 2 },
|
|
|
|
|
{ "one", "two" },
|
|
|
|
|
{ true, false },
|
|
|
|
|
{ new Vector3(0,1,2), new Vector3(1,2,3) },
|
|
|
|
|
{ CameraClearFlags.Depth, CameraClearFlags.Color },
|
|
|
|
|
{ "################################################\r\n##########", null },
|
|
|
|
|
{ "subdict", new Dictionary<object,object> { { "key", "value" } } }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public const int ConstantInt = 5;
|
|
|
|
|
|
|
|
|
|
public static byte[] ByteArray = new byte[16];
|
|
|
|
|
public static string LongString = new string('#', 10000);
|
|
|
|
|
public static List<string> BigList = new List<string>(10000);
|
|
|
|
|
|
|
|
|
|
public static List<object> RandomList
|
2021-05-01 20:55:27 +10:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var list = new List<object>();
|
|
|
|
|
int count = UnityEngine.Random.Range(0, 100);
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
list.Add(GetRandomObject());
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-05 21:27:09 +10:00
|
|
|
|
private static void TestGeneric<T>()
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.Log("Test1 " + typeof(T).FullName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void TestGenericClass<T>() where T : class
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.Log("Test2 " + typeof(T).FullName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//private static void TestGenericMultiInterface<T>() where T : IEnumerable, IList, ICollection
|
|
|
|
|
//{
|
|
|
|
|
// ExplorerCore.Log("Test3 " + typeof(T).FullName);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private static void TestComponent<T>() where T : Component
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.Log("Test3 " + typeof(T).FullName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void TestStruct<T>() where T : struct
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.Log("Test3 " + typeof(T).FullName);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-01 20:55:27 +10:00
|
|
|
|
private static object GetRandomObject()
|
|
|
|
|
{
|
|
|
|
|
object ret = null;
|
|
|
|
|
|
|
|
|
|
int ran = UnityEngine.Random.Range(0, 7);
|
|
|
|
|
switch (ran)
|
|
|
|
|
{
|
|
|
|
|
case 0: return null;
|
|
|
|
|
case 1: return 123;
|
|
|
|
|
case 2: return true;
|
|
|
|
|
case 3: return "hello";
|
|
|
|
|
case 4: return 50.5f;
|
|
|
|
|
case 5: return UnityEngine.CameraClearFlags.Color;
|
|
|
|
|
case 6: return new List<string> { "sub list", "lol" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2021-04-06 01:01:46 +10:00
|
|
|
|
|
2021-04-04 13:44:58 +10:00
|
|
|
|
#if CPP
|
|
|
|
|
public static string testStringOne = "Test";
|
|
|
|
|
public static Il2CppSystem.Object testStringTwo = "string boxed as cpp object";
|
|
|
|
|
public static Il2CppSystem.String testStringThree = "string boxed as cpp string";
|
|
|
|
|
public static string nullString = null;
|
|
|
|
|
|
2021-04-04 03:41:36 +10:00
|
|
|
|
public static Il2CppSystem.Collections.Hashtable testHashset;
|
2021-04-07 17:20:09 +10:00
|
|
|
|
public static Il2CppSystem.Collections.Generic.List<Il2CppSystem.Object> testList;
|
2021-05-04 20:10:46 +10:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public static Il2CppSystem.Nullable<Quaternion> NullableQuaternion;
|
|
|
|
|
//public static Il2CppSystem.Nullable<int> NullableInt = new Il2CppSystem.Nullable<int>(5);
|
|
|
|
|
//public static Il2CppSystem.Nullable<bool> NullableBool = new Il2CppSystem.Nullable<bool>(false);
|
2021-04-28 20:47:48 +10:00
|
|
|
|
#endif
|
2021-04-04 03:41:36 +10:00
|
|
|
|
|
|
|
|
|
static TestClass()
|
|
|
|
|
{
|
2021-05-03 21:02:01 +10:00
|
|
|
|
for (int i = 0; i < BigList.Capacity; i++)
|
|
|
|
|
BigList.Add(i.ToString());
|
|
|
|
|
|
2021-04-28 20:47:48 +10:00
|
|
|
|
#if CPP
|
2021-05-04 20:10:46 +10:00
|
|
|
|
//NullableQuaternion = new Il2CppSystem.Nullable<Quaternion>();
|
|
|
|
|
//NullableQuaternion.value = Quaternion.identity;
|
|
|
|
|
|
2021-04-04 03:41:36 +10:00
|
|
|
|
testHashset = new Il2CppSystem.Collections.Hashtable();
|
|
|
|
|
testHashset.Add("key1", "itemOne");
|
|
|
|
|
testHashset.Add("key2", "itemTwo");
|
|
|
|
|
testHashset.Add("key3", "itemThree");
|
2021-04-07 17:20:09 +10:00
|
|
|
|
|
|
|
|
|
testList = new Il2CppSystem.Collections.Generic.List<Il2CppSystem.Object>(3);
|
|
|
|
|
testList.Add("One");
|
|
|
|
|
testList.Add("Two");
|
|
|
|
|
testList.Add("Three");
|
2021-04-04 03:41:36 +10:00
|
|
|
|
#endif
|
2021-04-28 20:47:48 +10:00
|
|
|
|
}
|
2021-04-04 13:44:58 +10:00
|
|
|
|
}
|
2021-04-04 03:41:36 +10:00
|
|
|
|
}
|