Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. PlayerName Script:
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using TMPro;
  6. using UnityEngine.UI;
  7. using UnityEngine.Networking;
  8.  
  9. [System.Obsolete]
  10. public class PlayerNameMP : NetworkBehaviour
  11. {
  12. [SerializeField]
  13. private TextMeshProUGUI playerNameText;
  14.  
  15. [SerializeField]
  16. private PlayerMovementMP playerProf;
  17.  
  18. // Start is called before the first frame update
  19. void Start()
  20. {
  21.  
  22. }
  23.  
  24. // Update is called once per frame
  25. void Update()
  26. {
  27. playerNameText.text = playerProf.playerName;
  28. }
  29. }
  30.  
  31. PlayerProf Script:
  32. using UnityEngine;
  33. using TMPro;
  34. using UnityEngine.UI;
  35. using UnityEngine.Networking;
  36.  
  37. [System.Obsolete]
  38. public class PlayerMovementMP : NetworkBehaviour
  39. {
  40. [SyncVar] public string playerName = "Name";
  41.  
  42. private void Start()
  43. {
  44. if (isLocalPlayer)
  45. {
  46. Camera.main.gameObject.SetActive(true);
  47.  
  48. playerName = PlayerPrefs.GetString("Name");
  49.  
  50. }
  51. else
  52. GetComponentInChildren<Camera>().gameObject.SetActive(false);
  53. }
  54.  
  55. void Update()
  56. {
  57. if (!isLocalPlayer)
  58. {
  59. return;
  60. }
  61.  
  62. playerName = PlayerPrefs.GetString("Name");
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement