Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using BB.Utility;
- using System.Diagnostics;
- public class ClassAccessTest : MonoBehaviour
- {
- public Text iterationTxt;
- public Text resultTxt;
- public Text timeTxt;
- public PlayerClass somePlayerClass;
- public int iterationCount;
- public int step = 1000;
- private Stopwatch stopwatch = new Stopwatch();
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.Escape))
- this.iterationCount += step;
- this.stopwatch.Reset();
- this.stopwatch.Start();
- int healthValue = 0;
- for (int i = 0; i < iterationCount; i++)
- {
- healthValue = this.SomeAction();
- }
- this.stopwatch.Stop();
- this.iterationTxt.text = iterationCount.ToStringNonAlloc();
- this.resultTxt.text = healthValue.ToStringNonAlloc();
- this.timeTxt.text = ((int)stopwatch.ElapsedMilliseconds).ToStringNonAlloc();
- }
- private int SomeAction()
- {
- this.somePlayerClass.health = 10;
- this.somePlayerClass.ExampleFunction();
- int nHealth = this.somePlayerClass.health;
- return nHealth;
- }
- }
- [System.Serializable]
- public class PlayerClass
- {
- public int health;
- public void ExampleFunction()
- {
- this.health = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement