Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class CommunicationTest : PerformanceTest {
- GameObject objRef;
- CommTest scriptRef;
- public override void Initialise(int caseNumber)
- {
- objRef = new GameObject("communication test object "+caseNumber);
- scriptRef = objRef.AddComponent<CommTest>();
- }
- public override void Finish(int caseNumber)
- {
- GameObject.Destroy(objRef);
- objRef = null;
- scriptRef = null;
- }
- public override string[] CaseDescriptions {
- get {
- return new string[] {
- "SendMessage",
- "GetComponent",
- "Direct Call"
- };
- }
- }
- public override bool Test(int caseNumber)
- {
- switch (caseNumber) {
- case 0:
- objRef.SendMessage("TestFunction");
- break;
- case 1:
- objRef.GetComponent<CommTest>().TestFunction();
- break;
- case 2:
- scriptRef.TestFunction();
- break;
- }
- return false;
- }
- public bool ForceOneIteration { get { return false; } }
- }
- public class CommTest : MonoBehaviour
- {
- int n=0;
- public void TestFunction() {
- // do something arbitrary so compiler doesn't get clever and unroll it to nothing!
- n++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment