forked from MidLevel/MLAPI-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSyncVarTest.cs
More file actions
31 lines (27 loc) · 764 Bytes
/
Copy pathSyncVarTest.cs
File metadata and controls
31 lines (27 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Alpaca.Attributes;
using Alpaca.MonoBehaviours.Core;
using UnityEngine;
using UnityEngine.UI;
public class SyncVarTest : Conduct
{
[SyncedVar]
public string MySyncedName;
public Text TextField;
public GameObject prefab;
public override void NetworkStart()
{
if (isServer)
MySyncedName = "SyncVarTest: " + Random.Range(50, 10000) + " (Press space on server)";
}
private void Update()
{
TextField.text = MySyncedName;
if(isServer && Input.GetKeyDown(KeyCode.Space) && isLocalPlayer)
{
MySyncedName = "SyncVarTest: " + Random.Range(50, 10000) + " (Press space on server)";
GameObject go = Instantiate(prefab);
go.transform.position = transform.position + new Vector3(0, 1f, 0);
go.GetComponent<Entity>().Spawn();
}
}
}