-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer_Score.cs
49 lines (36 loc) · 1.21 KB
/
Player_Score.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using TMPro;
using UnityEngine.UI;
using System;
public class Player_Score : NetworkBehaviour
{
[SerializeField] private TMP_Text text_Player_Score_Name;
[SerializeField] private GameObject image_Player_Score;
[SerializeField] private TMP_Text Text_Player_Score_Points;
[SerializeField] public Sprite[] spritesList = new Sprite[6];
[SyncVar(hook = nameof(HandlePointsChanged))]
[SerializeField] public int Points = 0;
[SyncVar]
[SerializeField]
public string Player_name;
[SyncVar]
[SerializeField]
public int imageNum;
[Client]
public override void OnStartClient()
{
GameObject parent = GameObject.Find("Score_Layout_Group");
gameObject.transform.SetParent(parent.transform, false);
Text_Player_Score_Points.text = Points.ToString();
text_Player_Score_Name.text = Player_name;
image_Player_Score.GetComponent<Image>().sprite = spritesList[imageNum];
base.OnStartClient();
}
private void HandlePointsChanged(int oldValue, int newValue)
{
Text_Player_Score_Points.text = newValue.ToString();
}
}