Пример #1
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            GUIStyle style = new GUIStyle(GUI.skin.label);

            style.richText = true;
            LuaDeepProfilerSetting settings = (LuaDeepProfilerSetting)target;

            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Resources Path", GUI.skin.textField, style);
            settings.luaProjectPath = EditorGUILayout.TextField(GUIContent.none, settings.luaProjectPath);
            if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false)))
            {
                GUI.FocusControl(null);
                var path = EditorUtility.OpenFolderPanel("Locate Build Folder", settings.luaProjectPath, null);
                if (!String.IsNullOrEmpty(path))
                {
                    settings.luaProjectPath = MakePathRelativeToProject(path);
                }
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("start", GUILayout.ExpandWidth(true)))
            {
                Start();
            }
            if (GUILayout.Button("restore", GUILayout.ExpandWidth(true)))
            {
                Restore();
            }
            EditorGUILayout.EndVertical();
        }
Пример #2
0
        public static void OnStartGame()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            if (isInite)
            {
                return;
            }

            isInite = true;
            setting = LuaDeepProfilerSetting.MakeInstance();
            LuaProfiler.mainThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
            if (setting.isNeedCapture)
            {
                Screen.SetResolution(480, 270, true);
            }

            if (setting.isDeepLuaProfiler || setting.isDeepMonoProfiler || setting.isCleanMode)
            {
                GameObject go = new GameObject();
                go.name      = "MikuLuaProfiler";
                go.hideFlags = HideFlags.HideAndDontSave;
                DontDestroyOnLoad(go);
                go.AddComponent <HookLuaSetup>();
                NetWorkClient.ConnectServer(setting.ip, setting.port);
            }
        }
Пример #3
0
        public static LuaDeepProfilerSetting Load()
        {
            LuaDeepProfilerSetting result = new LuaDeepProfilerSetting();

            if (File.Exists(SettingsAssetName))
            {
                FileStream fs = new FileStream(SettingsAssetName, FileMode.OpenOrCreate);
                try
                {
                    BinaryReader b = new BinaryReader(fs);

                    result.m_isDeepProfiler = b.ReadBoolean();
                    result.m_captureLuaGC   = b.ReadInt32();
                    result.m_profilerMono   = b.ReadBoolean();
                    b.ReadBoolean();
                    result.m_isRecord     = b.ReadBoolean();
                    result.m_isNeedRecord = b.ReadBoolean();

                    int len = b.ReadInt32();
                    result.m_assMd5   = Encoding.UTF8.GetString(b.ReadBytes(len));
                    result.m_isInited = b.ReadBoolean();

                    len             = b.ReadInt32();
                    result.m_luaDir = Encoding.UTF8.GetString(b.ReadBytes(len));

                    len             = b.ReadInt32();
                    result.m_luaIDE = Encoding.UTF8.GetString(b.ReadBytes(len));

                    result.m_captureMonoGC    = b.ReadInt32();
                    result.m_captureFrameRate = b.ReadInt32();

                    b.Close();
                }
                catch
                {
                    fs.Dispose();
                    File.Delete(SettingsAssetName);
                    return(Load());
                }
            }
            else
            {
                result.Save();
            }

            return(result);
        }
Пример #4
0
        public static void OnStartGame()
        {
            setting = LuaDeepProfilerSetting.MakeInstance();
            LuaProfiler.mainThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
            if (setting.isNeedCapture)
            {
                Screen.SetResolution(480, 270, true);
            }

            if (setting.isDeepLuaProfiler || setting.isDeepMonoProfiler)
            {
                GameObject go = new GameObject();
                go.name      = "MikuLuaProfiler";
                go.hideFlags = HideFlags.HideAndDontSave;
                go.AddComponent <HookLuaSetup>();
                NetWorkClient.ConnectServer(setting.ip, setting.port);
            }
        }
Пример #5
0
            private static void InitPathDict()
            {
                if (m_isInited)
                {
                    return;
                }
                string[] paths = null;
                m_pathDict.Clear();

                LuaDeepProfilerSetting ls = LuaDeepProfilerSetting.Instance;
                string luaPath            = !ls.isDeepProfiler ? ls.luaProjectPath : ls.profilerLuaProjectPath;

                luaPath = luaPath.Replace('\\', '/');

                if (Directory.Exists(luaPath))
                {
                    paths = Directory.GetFiles(luaPath, "*" + LuaDeepProfilerSetting.Instance.luaExtern, SearchOption.AllDirectories);
                }
                if (paths == null)
                {
                    throw new System.Exception("lua director not exit");
                }

                for (int i = 0, imax = paths.Length; i < imax; i++)
                {
                    string thePath = paths[i].Replace('\\', '/');
                    string name    = Path.GetFileName(thePath);
                    string ext     = name.Split(new char[] { '.' }, 2)[1];

                    string fileName = thePath.Replace(luaPath + "/", "").Replace(LuaDeepProfilerSetting.Instance.luaExtern, "").Replace("/", ".").ToLower();
                    string strKey   = fileName.Split(new char[] { '.' })[0];
                    Debug.Log(strKey);

                    m_pathDict.Add(strKey, thePath);
                }
                m_isInited = true;
            }
Пример #6
0
 private void Awake()
 {
     NativeHelper.RunAyncPass();
     setting = LuaDeepProfilerSetting.Instance;
 }
 public static LuaDeepProfilerSetting MakeInstance()
 {
     instance = LuaDeepProfilerSetting.Load();
     return(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 = "Assets/Resources/LuaDeepProfilerSettings.bytes";
            if (!File.Exists(text))
            {
                luaDeepProfilerSetting.Save();
            }
            datas = File.ReadAllBytes(text);
#else
            TextAsset textAsset = null;
            string    path      = Application.persistentDataPath + "/LuaDeepProfilerSettings.bytes";
            if (File.Exists(path))
            {
                datas = File.ReadAllBytes(path);
            }
            else
            {
                textAsset = Resources.Load <TextAsset>("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);
        }
 private void Awake()
 {
     setting = LuaDeepProfilerSetting.Instance;
 }
Пример #10
0
        public static void OnStartGame()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
#if UNITY_EDITOR_WIN
            string path  = null;
            var    files = System.IO.Directory.GetFiles(Application.dataPath, "EasyHook64.bin", System.IO.SearchOption.AllDirectories);
            if (files.Length > 0)
            {
                path = files[0];
            }
            if (!string.IsNullOrEmpty(path))
            {
                IntPtr ptr = LoadLibrary(path);
                if (ptr == null)
                {
                    Debug.LogError("dont't move dll file to other place");
                    return;
                }
            }
            else
            {
                Debug.LogError("no EasyHook64.bin");
                return;
            }
#endif
            if (isInite)
            {
                return;
            }

            isInite = true;
            setting = LuaDeepProfilerSetting.Instance;
            LuaProfiler.mainThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
            if (setting.isNeedCapture)
            {
                Screen.SetResolution(480, 270, true);
            }

#if UNITY_EDITOR
            if (setting.isDeepLuaProfiler)
            {
                LuaDLL.Uninstall();
                LuaDLL.HookLoadLibrary();
                LuaDLL.BindEasyHook();
                //LuaDLL.Install();

                if (setting.isCleanMode)
                {
                    LuaProfilerPrecompileSetting.CompileLuaScript(false);
                }
            }
#endif

            if (setting.isDeepLuaProfiler || setting.isDeepMonoProfiler || setting.isCleanMode)
            {
                GameObject go = new GameObject();
                go.name      = "MikuLuaProfiler";
                go.hideFlags = HideFlags.HideAndDontSave;
                DontDestroyOnLoad(go);
                go.AddComponent <HookLuaSetup>();
                if (!setting.isLocal)
                {
                    NetWorkClient.ConnectServer(setting.ip, setting.port);
                }
            }
        }
Пример #11
0
        public static void OnStartGame()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
#if UNITY_EDITOR_WIN
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(true);
            System.Diagnostics.StackFrame sf = st.GetFrame(0);
            string path = sf.GetFileName();

            path = path.Replace("Core\\LuaHookSetup.cs", "Plugins\\EasyHook64.dll");
            IntPtr ptr = LoadLibrary(path);
            if (ptr == null)
            {
                Debug.LogError("dont't move dll file to other place");
                return;
            }
#endif
            if (isInite)
            {
                return;
            }

            isInite = true;
            setting = LuaDeepProfilerSetting.Instance;
            LuaProfiler.mainThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
            if (setting.isNeedCapture)
            {
                Screen.SetResolution(480, 270, true);
            }

#if UNITY_EDITOR
            if (setting.isDeepLuaProfiler)
            {
                LuaDLL.Uninstall();
                LuaDLL.HookLoadLibrary();
                LuaDLL.BindEasyHook();
                //LuaDLL.Install();

                if (setting.isCleanMode)
                {
                    LuaProfilerPrecompileSetting.CompileLuaScript(false);
                }
            }
#endif

            if (setting.isDeepLuaProfiler || setting.isDeepMonoProfiler || setting.isCleanMode)
            {
                GameObject go = new GameObject();
                go.name      = "MikuLuaProfiler";
                go.hideFlags = HideFlags.HideAndDontSave;
                DontDestroyOnLoad(go);
                go.AddComponent <HookLuaSetup>();
                if (!setting.isLocal)
                {
                    NetWorkClient.ConnectServer(setting.ip, setting.port);
                }
            }
        }