35 lines
760 B
C#
35 lines
760 B
C#
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();
|
|
}
|
|
}
|