Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Graze.js
- var grazeCount : int = 0;
- var bulletComp;
- function OnTriggerEnter (myTrigger : Collider)
- {
- if (myTrigger.CompareTag("EnemyBullet"))
- {
- bulletComp = myTrigger.GetComponent(EnemyBulletMove);
- if (bulletComp.grazed == false)
- {
- grazeCount += 1;
- bulletComp.grazed = true;
- }
- }
- }
- //ShowFPS.js
- var updateInterval = 0.5;
- var grazer : GameObject;
- var grazerComp;
- private var accum = 0.0; // FPS accumulated over the interval
- private var frames = 0; // Frames drawn over the interval
- private var timeleft : float; // Left time for current interval
- function Start()
- {
- if( !guiText )
- {
- print ("FramesPerSecond needs a GUIText component!");
- enabled = false;
- return;
- }
- timeleft = updateInterval;
- grazerComp = grazer.GetComponent(Graze);
- }
- function Update()
- {
- timeleft -= Time.deltaTime;
- accum += Time.timeScale/Time.deltaTime;
- ++frames;
- grazerComp = grazer.GetComponent(Graze);
- // Interval ended - update GUI text and start new interval
- if( timeleft <= 0.0 )
- {
- // display two fractional digits (f2 format)
- guiText.text = "FPS: " + (accum/frames).ToString("f2") + "\nGraze: " + grazerComp.grazeCount.ToString();
- timeleft = updateInterval;
- accum = 0.0;
- frames = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement