updated mirror added testofflinescene

This commit is contained in:
DerTyp187
2021-10-25 13:03:25 +02:00
parent 93244c5160
commit 5921e33205
18 changed files with 2551 additions and 14 deletions

View File

@@ -9,16 +9,25 @@ public class Player : NetworkBehaviour
public Team team;
[SerializeField] private const int defaultHp = 100;
public ulong clientId;
private string name;
[SyncVar(hook = nameof(SetName))]
public string username;
[SerializeField] GameObject usernameTextObj;
private int health;
private int kills;
private int deaths;
public void SetName(string newName)
public override void OnStartLocalPlayer()
{
name = newName;
base.OnStartClient();
}
public void SetName(string oldName, string newName)
{
username = newName;
usernameTextObj.GetComponent<TMPro.TextMeshPro>().SetText(username);
}
public string GetName()

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class PlayerColor : NetworkBehaviour
{
[SyncVar(hook = "SetColor")]
public Color color;
public Renderer renderer;
void SetColor(Color oldColor, Color newColor)
{
if (color == null)
{
color = renderer.material.color;
}
renderer.material.color = newColor;
color = newColor;
}
public override void OnStartClient()
{
renderer.material.color = color;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00dc60b61b501f2419e2abd7158be5f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: