Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PlayerName Script:
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- [System.Obsolete]
- public class PlayerNameMP : NetworkBehaviour
- {
- [SerializeField]
- private TextMeshProUGUI playerNameText;
- [SerializeField]
- private PlayerMovementMP playerProf;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- playerNameText.text = playerProf.playerName;
- }
- }
- PlayerProf Script:
- using UnityEngine;
- using TMPro;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- [System.Obsolete]
- public class PlayerMovementMP : NetworkBehaviour
- {
- [SyncVar] public string playerName = "Name";
- private void Start()
- {
- if (isLocalPlayer)
- {
- Camera.main.gameObject.SetActive(true);
- playerName = PlayerPrefs.GetString("Name");
- }
- else
- GetComponentInChildren<Camera>().gameObject.SetActive(false);
- }
- void Update()
- {
- if (!isLocalPlayer)
- {
- return;
- }
- playerName = PlayerPrefs.GetString("Name");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement