Ejemplo n.º 1
0
        //private static int tickNum = 0;
        static StartUp()
        {
            if (LuaDeepProfilerSetting.Instance.isDeepLuaProfiler)
            {
                InjectMethods.HookLuaFun();
            }
            if (LuaDeepProfilerSetting.Instance.isDeepMonoProfiler)
            {
                InjectMethods.InjectAllMethods();
            }

#if XLUA || TOLUA || SLUA
            if (LuaDeepProfilerSetting.Instance.isInited)
            {
                return;
            }
#endif
            string[] paths = Directory.GetFiles(Application.dataPath, "*.dll", SearchOption.AllDirectories);
            foreach (var item in paths)
            {
                string fileName = Path.GetFileName(item);
                if (fileName == "slua.dll")
                {
                    AppendMacro("#define SLUA");
                }

                if (fileName == "xlua.dll")
                {
                    AppendMacro("#define XLUA");
                    break;
                }

                if (fileName == "tolua.dll")
                {
                    AppendMacro("#define TOLUA");
                    break;
                }
            }

            LuaDeepProfilerSetting.Instance.isInited = true;
        }
        void DoToolbar()
        {
            var setting = LuaDeepProfilerSetting.Instance;

            #region profiler settting
            GUILayout.Label("profiler setting");
            GUILayout.BeginVertical("Box");

            EditorGUILayout.BeginHorizontal();
            bool flag = GUILayout.Toggle(setting.isDeepLuaProfiler, "Deep Profiler Lua");
            if (flag != setting.isDeepLuaProfiler)
            {
                setting.isDeepLuaProfiler = flag;
                if (!flag)
                {
                    setting.isCleanMode = false;
                }
                EditorApplication.isPlaying = false;
                InjectMethods.Recompile();
            }

            flag = GUILayout.Toggle(setting.isCleanMode, "PreCompile Lua");
            if (flag != setting.isCleanMode)
            {
                setting.isCleanMode = flag;
                if (setting.isCleanMode)
                {
                    setting.isDeepLuaProfiler = true;
                }
                EditorApplication.isPlaying = false;
            }

            flag = GUILayout.Toggle(setting.isDeepMonoProfiler, "Deep Profiler Mono");
            if (flag != setting.isDeepMonoProfiler)
            {
                setting.isDeepMonoProfiler  = flag;
                EditorApplication.isPlaying = false;
                InjectMethods.Recompile();
            }

            flag = GUILayout.Toggle(setting.discardInvalid, "Discard Invalid");
            if (flag != setting.discardInvalid)
            {
                setting.discardInvalid = flag;
            }

            EditorGUILayout.EndHorizontal();

            //GUILayout.Space(5);
            //if (GUILayout.Button("Inject Method", GUILayout.Height(50)))
            //{
            //    InjectMethods.InjectAllMethods();
            //}
            GUILayout.Space(5);
            if (GUILayout.Button("ReCompile", GUILayout.Height(50)))
            {
                InjectMethods.Recompile();
            }
            GUILayout.Space(5);

            GUILayout.EndVertical();
            #endregion

            #region socket
            GUILayout.Space(10);
            GUILayout.Label("connet");

            GUILayout.BeginVertical("Box");
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("ip:", GUILayout.Height(30), GUILayout.Width(35));
            setting.ip = EditorGUILayout.TextField(setting.ip, GUILayout.Height(16), GUILayout.Width(100));

            GUILayout.Label("port:", GUILayout.Height(30), GUILayout.Width(35));
            setting.port = EditorGUILayout.IntField(setting.port, GUILayout.Height(16), GUILayout.Width(50));
            EditorGUILayout.EndHorizontal();

            /*
             * if (GUILayout.Button("Connent", GUILayout.Height(50)))
             * {
             *  NetWorkClient.ConnectServer(setting.ip, setting.port);
             * }
             * GUILayout.Space(5);*/

            GUILayout.EndVertical();
            #endregion

            #region capture

            /*
             * GUILayout.Space(10);
             *
             * GUILayout.Label("capture setting");
             * GUILayout.BeginVertical("Box");
             *
             * flag = GUILayout.Toggle(LuaDeepProfilerSetting.Instance.isNeedCapture, "NeedCapture");
             * if (flag != LuaDeepProfilerSetting.Instance.isNeedCapture)
             * {
             *  LuaDeepProfilerSetting.Instance.isNeedCapture = flag;
             *  if (flag)
             *  {
             *      GameViewUtility.ChangeGameViewSize(480, 270);
             *  }
             * }
             *
             * GUILayout.Space(10);
             *
             * EditorGUILayout.BeginHorizontal();
             * GUILayout.Label("lua gc", GUILayout.Height(30), GUILayout.Width(45));
             * LuaDeepProfilerSetting.Instance.captureLuaGC
             *  = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureLuaGC, GUILayout.Height(16), GUILayout.Width(50));
             * LuaDeepProfilerSetting.Instance.captureLuaGC = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureLuaGC);
             * GUILayout.Label("B", GUILayout.Height(30), GUILayout.Width(20));
             *
             * GUILayout.Label("mono gc", GUILayout.Height(30), GUILayout.Width(55));
             * LuaDeepProfilerSetting.Instance.captureMonoGC
             *  = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureMonoGC, GUILayout.Height(16), GUILayout.Width(50));
             * LuaDeepProfilerSetting.Instance.captureMonoGC = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureMonoGC);
             * GUILayout.Label("B", GUILayout.Height(30), GUILayout.Width(20));
             *
             * GUILayout.Label("capture ", GUILayout.Height(30), GUILayout.Width(50));
             * LuaDeepProfilerSetting.Instance.captureFrameRate
             *  = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureFrameRate, GUILayout.Height(16), GUILayout.Width(50));
             * LuaDeepProfilerSetting.Instance.captureFrameRate = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureFrameRate);
             * GUILayout.Label("FPS", GUILayout.Height(30), GUILayout.Width(30));
             *
             * EditorGUILayout.EndHorizontal();
             *
             * GUILayout.EndVertical();
             */
            #endregion
        }