Example #1
0
        public static void OnStartGame()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            if (isInite)
            {
                return;
            }
            LuaDeepProfilerSetting.MakeInstance();
            isInite = true;
            setting = LuaDeepProfilerSetting.Instance;
            LuaProfiler.mainThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
            if (setting.isNeedCapture)
            {
                Screen.SetResolution(480, 270, true);
            }

#if UPR_LUA_PROFILER
#if DEPLICATED
            LuaDLL.Install();
#endif

            GameObject go = new GameObject();
            go.name      = "UPRLuaProfiler";
            go.hideFlags = HideFlags.HideAndDontSave;
            DontDestroyOnLoad(go);
            go.AddComponent <HookLuaSetup>();
            NetWorkClient.ConnectServer(setting.ip, setting.port);
#endif
        }
 public static LuaDeepProfilerSetting MakeInstance()
 {
     instance = LuaDeepProfilerSetting.Load();
     return(instance);
 }
Example #3
0
 private void Awake()
 {
     setting = LuaDeepProfilerSetting.Instance;
 }
        // 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);
        }