Example #1
0
        public void Start()
        {
            //Set Server IP in info label
            GameObject lowerDetailTextGameObject = playerSettingsPanel.RequireGameObject("LowerDetail/Text");

            lowerDetailTextGameObject.GetComponent <Text>().text = $"IP адрес сервера\n{ServerIp}";

            //Initialize elements from preferences
            activePlayerPreference = preferencesManager.GetPreference(ServerIp);

            float hue;
            float saturation;
            float vibrance;

            Color playerColor = new Color(activePlayerPreference.RedAdditive, activePlayerPreference.GreenAdditive, activePlayerPreference.BlueAdditive);

            Color.RGBToHSV(playerColor, out hue, out saturation, out vibrance);
            uGUI_ColorPicker colorPicker = playerSettingsPanel.GetComponentInChildren <uGUI_ColorPicker>();

            colorPicker.SetHSB(new Vector3(hue, 1f, vibrance));

            GameObject playerNameInputFieldGameObject = playerSettingsPanel.RequireGameObject("InputField");

            uGUI_InputField playerNameInputField = playerNameInputFieldGameObject.GetComponent <uGUI_InputField>();

            playerNameInputField.text = activePlayerPreference.PlayerName;

            StartMultiplayerClient();
        }
Example #2
0
        public void Show(string ip, int port)
        {
            NitroxServiceLocator.BeginNewLifetimeScope();
            multiplayerSession = NitroxServiceLocator.LocateService <IMultiplayerSession>();
            preferencesManager = NitroxServiceLocator.LocateService <PlayerPreferenceManager>();

            gameObject.SetActive(true);
            serverIp   = ip;
            serverPort = port;

            //Set Server IP in info label
            lowerDetailTextGameObject.GetComponent <Text>().text = $"{Language.main.Get("Nitrox_JoinServerIpAddress")}\n{(NitroxPrefs.HideIp.Value ? "****" : serverIp)}";

            //Initialize elements from preferences
            activePlayerPreference = preferencesManager.GetPreference(serverIp);
            SubscribeColorChanged();

            // HSV => Hue Saturation Value, HSB => Hue Saturation Brightness
            Color.RGBToHSV(activePlayerPreference.PreferredColor(), out float hue, out _, out float brightness);
            colorPicker.SetHSB(new Vector3(hue, 1f, brightness));

            playerNameInputField.text = activePlayerPreference.PlayerName;

            StartMultiplayerClient();
        }