void TestHeapVariableGet() { GameObject newObject = VRCInstantiate(referenceSpawnObject); // Have a separate case that will force find the script because of the above issue. We know in this specific test case that the only UdonBehaviour on the object will be of the type `InstantiatedObjectTesterScript` InstantiatedObjectTesterScript testScript = (InstantiatedObjectTesterScript)newObject.GetComponent(typeof(UdonBehaviour)); tester.TestAssertion("Instantiated Object Get Field", testScript.testValueStr == "test"); Destroy(newObject); }
void TestHeapVariableGetComponent() { GameObject newObject = VRCInstantiate(referenceSpawnObject); InstantiatedObjectTesterScript testScript = newObject.GetComponent <InstantiatedObjectTesterScript>(); // GetComponent<User T>() will fail immediately after instantiation because the script ID heap variable returns null, so U# has no way to determine the script type tester.TestAssertion("Instantiated Object GetComponent<T>()", testScript != null); Destroy(newObject); }
void TestHeapVariableSet() { GameObject newObject = VRCInstantiate(referenceSpawnObject); InstantiatedObjectTesterScript testScript = (InstantiatedObjectTesterScript)newObject.GetComponent(typeof(UdonBehaviour)); testScript.testValueStr = "test set"; tester.TestAssertion("Instantiated Object Set Field", testScript.testValueStr == "test set"); Destroy(newObject); }
void TestCustomEvent() { spawnCounter = 0; GameObject newObject = VRCInstantiate(referenceSpawnObject); InstantiatedObjectTesterScript testScript = (InstantiatedObjectTesterScript)newObject.GetComponent(typeof(UdonBehaviour)); testScript.spawnerBehaviour = this; testScript.CallEvent(); tester.TestAssertion("Instantiated Object Send Event", spawnCounter == 1); Destroy(newObject); }