ReLoadCurrentSettings









How do I use Re Load Current Settings
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonEditor.cs Copy
827     {
828         get
829         {
830             if (currentSettings == null)
831             {
832                 // find out if ServerSettings can be instantiated (existing script check)
833                 ScriptableObject serverSettingTest = CreateInstance("ServerSettings");
834                 if (serverSettingTest == null)
835                 {
836                     Debug.LogError(CurrentLang.ServerSettingsMissingLabel);
837                     return null;
838                 }
839                 DestroyImmediate(serverSettingTest);
840
841                 // try to load settings from file
842                 ReLoadCurrentSettings();
843
844                 // if still not loaded, create one
845                 if (currentSettings == null)
846                 {
847                     string settingsPath = Path.GetDirectoryName(PhotonNetwork.serverSettingsAssetPath);
848                     if (!Directory.Exists(settingsPath))
849                     {
850                         Directory.CreateDirectory(settingsPath);
851                         AssetDatabase.ImportAsset(settingsPath);
852                     }
853
854                     currentSettings = (ServerSettings)ScriptableObject.CreateInstance("ServerSettings");
855                     if (currentSettings != null)
856                     {
857                         AssetDatabase.CreateAsset(currentSettings, PhotonNetwork.serverSettingsAssetPath);
858                     }
859                     else
860                     {
861                         Debug.LogError(CurrentLang.ServerSettingsMissingLabel);
862                     }
863                 }
864
865                 // settings were loaded or created. set this editor's initial selected region now (will be changed in GUI)
866                 if (currentSettings != null)
867                 {
868                     selectedRegion = currentSettings.PreferredRegion;
869                 }
870             }
871
872             return currentSettings;
873         }
874
875         protected set
876         {
877             currentSettings = value;
878         }
879     }
File name: PhotonEditor.cs Copy
886     public static void ReLoadCurrentSettings()
887     {
888         // this now warns developers if there are more than one settings files in resources folders. first will be used.
889         UnityEngine.Object[] settingFiles = Resources.LoadAll(PhotonNetwork.serverSettingsAssetFile, typeof(ServerSettings));
890         if (settingFiles != null && settingFiles.Length > 0)
891         {
892             PhotonEditor.Current = (ServerSettings)settingFiles[0];
893
894             if (settingFiles.Length > 1)
895             {
896                 Debug.LogWarning(CurrentLang.MoreThanOneLabel + PhotonNetwork.serverSettingsAssetFile + CurrentLang.FilesInResourceFolderLabel + AssetDatabase.GetAssetPath(PhotonEditor.Current));
897             }
898         }
899     }

ReLoadCurrentSettings 118 lượt xem

Gõ tìm kiếm nhanh...