Пример #1
0
        public UPRToolSetting Load()
        {
            UPRToolSetting uprToolSetting = new UPRToolSetting();

            string    tempFilePath = string.Empty;
            TextAsset tempAsset    = Resources.Load <TextAsset>(Path.GetFileNameWithoutExtension(UPRSettingFile));
            var       datas        = tempAsset?.bytes;

            if (datas == null)
            {
                Debug.LogWarningFormat("[UPRToolSetting] can't load {0} at {1},just creat it.", UPRSettingFile, tempFilePath);
                Save();
                return(uprToolSetting);
            }

            using (var memoryStream = new MemoryStream(datas))
            {
                using (var binaryReader = new BinaryReader(memoryStream))
                {
                    uprToolSetting.m_loadScene       = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadAsset       = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadAssetBundle = binaryReader.ReadBoolean();
                    uprToolSetting.m_instantiate     = binaryReader.ReadBoolean();
                }
            }

            return(uprToolSetting);
        }
Пример #2
0
 public static UPRToolSetting MakeInstance()
 {
     instance = UPRToolSetting.Load();
     return(instance);
 }
Пример #3
0
        public static UPRToolSetting Load()
        {
            UPRToolSetting uprToolSetting = new UPRToolSetting();

            byte[] datas = null;
    #if UNITY_EDITOR
            string text = "Assets/UPRTools/Resources/UPRToolSettings.bytes";
            if (!File.Exists(text))
            {
                uprToolSetting.Save();
            }
            datas = File.ReadAllBytes(text);
    #else
            TextAsset textAsset = null;
            string    path      = Application.persistentDataPath + "/UPRToolSettings.bytes";
            if (File.Exists(path))
            {
                datas = File.ReadAllBytes(path);
            }
            else
            {
                textAsset = Resources.Load <TextAsset>("UPRToolSettings");
                datas     = textAsset != null ? textAsset.bytes : null;
            }
    #endif

            if (datas != null)
            {
                MemoryStream memoryStream = new MemoryStream(datas);
                try
                {
                    BinaryReader binaryReader = new BinaryReader(memoryStream);
                    uprToolSetting.m_enableLuaProfiler  = binaryReader.ReadBoolean();
                    uprToolSetting.m_enableMonoProfiler = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadScene          = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadAsset          = binaryReader.ReadBoolean();
                    uprToolSetting.m_loadAssetBundle    = binaryReader.ReadBoolean();
                    uprToolSetting.m_instantiate        = binaryReader.ReadBoolean();
                    binaryReader.Close();
                }
                catch
                {
    #if UNITY_EDITOR
                    memoryStream.Dispose();
                    File.Delete(text);
                    return(UPRToolSetting.Load());
    #endif
                }
            }
            else
            {
                uprToolSetting.Save();
            }

    #if !UNITY_EDITOR
            if (!File.Exists(path))
            {
                File.WriteAllBytes(path, datas);
            }
            if (textAsset != null)
            {
                Resources.UnloadAsset(textAsset);
            }
    #endif

            return(uprToolSetting);
        }
Пример #4
0
 private void OnProjectChange()
 {
     _UPRSetting = UPRToolSetting.Instance;
 }
Пример #5
0
 private void OnEnable()
 {
     _UPRSetting = UPRToolSetting.Instance;
 }