/// <summary>
 /// set values to those of other Settings
 /// </summary>
 void SetToNew(NetworkSettings newSet)
 {
     serverAddress = newSet.serverAddress;
     maxPeerCount  = newSet.maxPeerCount;
     connectionKey = newSet.connectionKey;
     port          = newSet.port;
 }
        /// <summary>
        /// loads data from file
        /// </summary>
        public void Load(string fileName)
        {
            try
            {
                Stream stream = File.OpenRead(fileName);
                stream.Position = 0;
                DataContractJsonSerializer ser    = new DataContractJsonSerializer(typeof(NetworkSettings));
                NetworkSettings            newSet = ser.ReadObject(stream) as NetworkSettings;
                SetToNew(newSet);
                stream.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error\n" + e);
                DefaultInitialize();
            }

            saved = true;
        }
    private void OnGUI()
    {
        GUILayout.Label("Connection Settings", EditorStyles.boldLabel);

        // settings
        if (null == settings)
        {
            settings = new Network.NetworkSettings();
            settings.Load();
        }

        EditorGUI.BeginChangeCheck();
        settings.serverAddress = EditorGUILayout.TextField("Server Address", settings.serverAddress);
        settings.maxPeerCount  = EditorGUILayout.IntField("Max Peer Count", settings.maxPeerCount);
        settings.connectionKey = EditorGUILayout.TextField("Connection Key", settings.connectionKey);
        settings.port          = EditorGUILayout.IntField("Port", settings.port);
        if (EditorGUI.EndChangeCheck())
        {
            settings.saved = false;
        }

        // status
        GUILayout.Label("Status: " + (settings.saved ? "saved" : "unsaved"), EditorStyles.label, null);

        // save
        if (GUILayout.Button("Save"))
        {
            settings.Save();
            ((ClientWindow)GetWindow(typeof(ClientWindow), false, null, false)).SetSettings(settings);
        }

        if (GUILayout.Button("Reload"))
        {
            settings.Load();
        }
    }
예제 #4
0
 public void LoadSettings()
 {
     settings = new NetworkSettings();
     settings.Load(LocationVariables.settingsLocation);
 }
 private void Awake()
 {
     settings = new Network.NetworkSettings();
     settings.Load();
 }