Exemplo n.º 1
0
 public static LuaDeepProfilerSetting MakeInstance()
 {
     instance = LuaDeepProfilerSetting.Load();
     return(instance);
 }
Exemplo n.º 2
0
        // Token: 0x060000C9 RID: 201 RVA: 0x00006674 File Offset: 0x00004A74
        public static LuaDeepProfilerSetting Load()
        {
            LuaDeepProfilerSetting luaDeepProfilerSetting = new LuaDeepProfilerSetting();

            byte[] datas = null;
#if UNITY_EDITOR
            string text = Path.Combine(UPRToolSetting.ResourcesDir, LuaDeepProfilerSettings);
            if (!File.Exists(text))
            {
                luaDeepProfilerSetting.Save();
            }
            datas = File.ReadAllBytes(text);
#else
            TextAsset textAsset = null;
            string    path      = Path.Combine(Application.persistentDataPath, LuaDeepProfilerSettings);
            if (File.Exists(path))
            {
                datas = File.ReadAllBytes(path);
            }
            else
            {
                textAsset = Resources.Load <TextAsset>(Path.GetFileNameWithoutExtension(LuaDeepProfilerSettings));
                datas     = textAsset != null ? textAsset.bytes : null;
            }
#endif

            if (datas != null)
            {
                MemoryStream memoryStream = new MemoryStream(datas);
                try
                {
                    BinaryReader binaryReader = new BinaryReader(memoryStream);
                    luaDeepProfilerSetting.m_isDeepMonoProfiler = binaryReader.ReadBoolean();
                    luaDeepProfilerSetting.m_isDeepLuaProfiler  = binaryReader.ReadBoolean();
                    luaDeepProfilerSetting.m_captureLuaGC       = binaryReader.ReadInt32();
                    luaDeepProfilerSetting.m_isInited           = binaryReader.ReadBoolean();
                    luaDeepProfilerSetting.m_isNeedCapture      = binaryReader.ReadBoolean();
                    luaDeepProfilerSetting.m_captureMonoGC      = binaryReader.ReadInt32();
                    luaDeepProfilerSetting.m_captureFrameRate   = binaryReader.ReadInt32();
                    int count = binaryReader.ReadInt32();
                    luaDeepProfilerSetting.m_assMd5 = Encoding.UTF8.GetString(binaryReader.ReadBytes(count));
                    count = binaryReader.ReadInt32();
                    luaDeepProfilerSetting.m_ip             = Encoding.UTF8.GetString(binaryReader.ReadBytes(count));
                    luaDeepProfilerSetting.m_port           = binaryReader.ReadInt32();
                    luaDeepProfilerSetting.m_discardInvalid = binaryReader.ReadBoolean();
                    luaDeepProfilerSetting.m_isCleanMode    = binaryReader.ReadBoolean();
                    binaryReader.Close();
                }
                catch
                {
#if UNITY_EDITOR
                    memoryStream.Dispose();
                    File.Delete(text);
                    return(LuaDeepProfilerSetting.Load());
#endif
                }
            }
            else
            {
                luaDeepProfilerSetting.Save();
            }
#if !UNITY_EDITOR
            if (!File.Exists(path))
            {
                File.WriteAllBytes(path, datas);
            }
            if (textAsset != null)
            {
                Resources.UnloadAsset(textAsset);
            }
#endif
            return(luaDeepProfilerSetting);
        }