13using System.Collections;
19 public abstract class LeapTestBase {
21 protected GameObject testObj;
32 protected virtual void InitTest(
string objectName) {
33 testObj = LoadObject(objectName);
36 #region Spawn Utilities
38 protected T Spawn<T>(T original, Vector3 position) where T : MonoBehaviour {
39 return GameObject.Instantiate<T>(original,
41 original.transform.rotation,
42 original.transform.parent);
45 protected GameObject Spawn(GameObject original, Vector3 position) {
46 return GameObject.Instantiate(original,
48 original.transform.rotation,
49 original.transform.parent);
61 protected GameObject LoadObject(
string objectName) {
62 GameObject obj =
null;
64 for (
int i = 0; i < SceneManager.sceneCount; i++) {
65 var scene = SceneManager.GetSceneAt(i);
67 obj = scene.GetRootGameObjects()
69 .FirstOrDefault(g => g.name == objectName);
78 var prefab = EditorResources.Load<GameObject>(objectName);
81 throw new Exception(
"Could not find an object or prefab with the name "
93 #region Frame Utilities
95 protected const bool GO_SLOW =
false;
97 protected int aBit {
get {
return GO_SLOW ? 50 : 5; } }
98 protected int aWhile {
get {
return GO_SLOW ? 200 : 20; } }
99 protected int aLot {
get {
return GO_SLOW ? 1000 : 100; } }
101 protected int beginningTestWait {
get {
return aBit; } }
102 protected int endingTestWait {
get {
return aWhile; } }
104 protected IEnumerator wait(
int numFrames) {
105 for (
int i = 0; i < numFrames; i++) {