Initial
This commit is contained in:
commit
36a53f343e
1 changed files with 300431 additions and 0 deletions
35
UnityProject/Assets/Scripts/misc/carCount.cs
Normal file
35
UnityProject/Assets/Scripts/misc/carCount.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
/* A pályát elhagyó autókat (robbanás nem számít) számolja, és írja ki a 3D textbe.
|
||||
*/
|
||||
|
||||
[NetworkSettings(channel = 0, sendInterval = 0.5f)]
|
||||
public class carCount : NetworkBehaviour {
|
||||
|
||||
[SyncVar]
|
||||
public int throughput = 0;
|
||||
|
||||
//Csak akkor updateli a szöveget, ha szükséges.
|
||||
private int previous = 0;
|
||||
|
||||
public void Update ()
|
||||
{
|
||||
if (isServer) return;
|
||||
|
||||
if(throughput != previous)
|
||||
{
|
||||
previous = throughput;
|
||||
GetComponent<TextMesh>().text = throughput.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[Server]
|
||||
public void IncrementValue()
|
||||
{
|
||||
throughput++;
|
||||
GetComponent<TextMesh>().text = throughput.ToString();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue