Cleanup, use Time.realTimeSinceStartup instead of Time.time, add some stuff

This commit is contained in:
Sinai
2021-05-03 21:02:01 +10:00
parent ad61ff243a
commit 8d9d8f76c2
22 changed files with 321 additions and 198 deletions

View File

@ -1,13 +1,70 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace UnityExplorer.Tests
{
public static class TestClass
{
public static List<object> List
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
{
get
{
@ -38,11 +95,6 @@ namespace UnityExplorer.Tests
return ret;
}
public const int ConstantInt = 5;
public static byte[] ByteArray = new byte[16];
public static string LongString = new string('#', 10000);
#if CPP
public static string testStringOne = "Test";
public static Il2CppSystem.Object testStringTwo = "string boxed as cpp object";
@ -55,6 +107,9 @@ namespace UnityExplorer.Tests
static TestClass()
{
for (int i = 0; i < BigList.Capacity; i++)
BigList.Add(i.ToString());
#if CPP
testHashset = new Il2CppSystem.Collections.Hashtable();
testHashset.Add("key1", "itemOne");

View File

@ -12,6 +12,19 @@ namespace UnityExplorer
{
public static class UnityHelpers
{
// Time helpers, can't use Time.time since timeScale will affect it.
// default 10ms (one frame at 100fps)
public static bool OccuredEarlierThanDefault(this float time)
{
return Time.realtimeSinceStartup - 0.01f >= time;
}
public static bool OccuredEarlierThan(this float time, float secondsAgo)
{
return Time.realtimeSinceStartup - secondsAgo >= time;
}
/// <summary>
/// Check if an object is null, and if it's a UnityEngine.Object then also check if it was destroyed.
/// </summary>