Exemple #1
0
 public static UPRToolSetting MakeInstance()
 {
     instance = UPRToolSetting.Load();
     return(instance);
 }
Exemple #2
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);
        }