Ejemplo n.º 1
0
        void Start()
        {
            _identity              = GetComponent <PlayerIdentity>();
            _identity.NameChanged += name =>
            {
                if (_playerNameText != null)
                {
                    _playerNameText.text = name;
                }
            };

            var canvas = GameObject.FindObjectOfType <Canvas>();

            if (canvas != null)
            {
                if (PlayerUIPrefab != null)
                {
                    _uiObject            = (GameObject)Instantiate(PlayerUIPrefab, canvas.transform);
                    _playerNameText      = _uiObject.GetComponentInChildren <Text>();
                    _playerNameText.text = _identity.Name;
                }
                else
                {
                    Debug.LogWarning("Player's UI prefab is not set");
                }
            }
            else
            {
                Debug.LogWarning("Can't find main UI container");
            }
        }
Ejemplo n.º 2
0
        void Start()
        {
            if (_identity == null)
            {
                _identity = GetComponent <PlayerIdentity>();
            }

            // if it is not a local player than set identity from SyncVars
            if (!isLocalPlayer)
            {
                _identity.SetColor(_colorSync);
                _identity.SetName(_nameSync);
                _identity.SetHat(_hatNameSync);
            }

            PlayersList.Players.Add(this);
        }
Ejemplo n.º 3
0
        public override void OnStartLocalPlayer()
        {
            if (_identity == null)
            {
                _identity = GetComponent <PlayerIdentity>();
            }

            // load identity from player prefs
            _identity.SetFromPlayerPrefs();

            // local authority must set its syncvars
            if (!isServer && hasAuthority)
            {
                _colorSync   = _identity.Color;
                _hatNameSync = _identity.HatName;
                _nameSync    = _identity.Name;
            }

            // Tell about yourself to everyone
            CmdSetIdentity(_identity.Name, _identity.Color, _identity.HatName);
        }