public void ShowLog(string fileName, Dictionary <string, LuaTypes> refDict, Dictionary <string, List <string> > detailDict)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var item in refDict)
            {
                List <string> list  = null;
                string        key   = item.Key;
                string        value = item.Value.ToString();
                if (detailDict.TryGetValue(key, out list))
                {
                    sb.AppendLine("type:" + value);
                    for (int i = 0, imax = list.Count; i < imax; i++)
                    {
                        if (i == imax - 1)
                        {
                            sb.AppendLine(" └─ref" + (i + 1) + " url:" + list[i]);
                        }
                        else
                        {
                            sb.AppendLine(" ├─ref" + (i + 1) + " url:" + list[i]);
                        }
                    }
                }
            }
            LuaProfilerWindow.ClearConsole();
            if (!Directory.Exists(Application.dataPath.Replace("Assets", "Diff")))
            {
                Directory.CreateDirectory(Application.dataPath.Replace("Assets", "Diff"));
            }
            string path = Application.dataPath.Replace("Assets", "Diff/" + fileName + ".txt");

            File.WriteAllText(path, sb.ToString());
            System.Diagnostics.Process.Start("explorer.exe", Application.dataPath.Replace("Assets", "Diff").Replace("/", "\\"));
        }
        public void LogToFile()
        {
            if (m_refDict == null)
            {
                return;
            }
            for (byte i = 1, imax = 2; i <= imax; i++)
            {
                RefDict       dictItem = m_refDict[i];
                StringBuilder sb       = new StringBuilder();
                List <KeyValuePair <string, int> > list = new List <KeyValuePair <string, int> >();
                foreach (var item in dictItem)
                {
                    list.Add(new KeyValuePair <string, int>(item.Key, item.Value.Count));
                }

                list.Sort((a, b) =>
                {
                    return(b.Value - a.Value);
                });

                foreach (var item in list)
                {
                    sb.AppendLine(string.Format("{0} count:{1}", item.Key, item.Value));
                }
                showStr = sb.ToString();

                LuaProfilerWindow.ClearConsole();
                if (!Directory.Exists(Application.dataPath.Replace("Assets", "Ref")))
                {
                    Directory.CreateDirectory(Application.dataPath.Replace("Assets", "Ref"));
                }
                if (i == 1)
                {
                    string path = Application.dataPath.Replace("Assets", "Ref/" + "function" + ".txt");
                    File.WriteAllText(path, sb.ToString());
                }
                else
                {
                    string path = Application.dataPath.Replace("Assets", "Ref/" + "table" + ".txt");
                    File.WriteAllText(path, sb.ToString());
                }
            }
            System.Diagnostics.Process.Start("explorer.exe", Application.dataPath.Replace("Assets", "Ref").Replace("/", "\\"));
        }
        protected override void DoubleClickedItem(int id)
        {
            base.DoubleClickedItem(id);
            if (string.IsNullOrEmpty(searchString))
            {
                var selectItem = FindItem(id, BuildRoot());
                var item       = (LuaProfilerTreeViewItem)selectItem;
                LuaProfilerWindow.ClearConsole();
                Debug.Log(item.displayName);

                /*
                 * if (item.line == -1)
                 * {
                 *  Debug.Log("please wait");
                 *  return;
                 * }
                 *
                 * string fileName = item.filePath;
                 * Debug.Log(fileName);
                 * try
                 * {
                 *  int line = item.line;
                 *  if (!File.Exists(fileName))
                 *  {
                 *      Debug.Log(fileName);
                 *  }
                 *  LocalToLuaIDE.OnOpenAsset(fileName, line);
                 * }
                 * catch
                 * {
                 * }*/
            }
            else
            {
                searchString = "";
                Reload();
                foreach (var item in roots)
                {
                    SetExpandedRecursive(item.id, false);
                }
                FrameItem(id);
            }
        }
示例#4
0
        public void DrawItemInfo(string key, string value, Dictionary <string, List <string> > dict)
        {
            GUILayout.BeginHorizontal();
            List <string> list = null;

            dict.TryGetValue(key, out list);
            int count = list == null ? 0 : list.Count;

            GUILayout.Label(string.Format("Key:{0}", key), GUILayout.Width(400));
            GUILayout.Label(string.Format("Value:{0}", value));
            GUILayout.Label(string.Format("Ref Count:{0}", count));
            if (GUILayout.Button("detail", GUILayout.Width(100)))
            {
                m_detailList = list == null ? m_detailList : list;
                StringBuilder sb = new StringBuilder();
                foreach (var item in m_detailList)
                {
                    sb.AppendLine(item);
                }
                LuaProfilerWindow.ClearConsole();
                Debug.Log(sb.ToString());
            }
            GUILayout.EndHorizontal();
        }
示例#5
0
        public void DoRefScroll()
        {
            if (m_isRecord)
            {
                EditorGUILayout.LabelField(m_dateTime);
            }
            if (luaDiff == null)
            {
                return;
            }

            GUILayout.BeginHorizontal();

            #region value
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("add values count:" + luaDiff.addRef.Count, GUILayout.Width(150));
            if (GUILayout.Button("ShowLog", GUILayout.Width(100)))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("add:");
                foreach (var item in luaDiff.addRef)
                {
                    List <string> list  = null;
                    string        key   = item.Key;
                    string        value = item.Value.ToString();
                    if (luaDiff.addDetail.TryGetValue(key, out list))
                    {
                        foreach (var itemx in list)
                        {
                            sb.Append("Key:");
                            sb.Append(itemx);
                            sb.Append(" ValueType:");
                            sb.AppendLine(value);
                        }
                        sb.AppendLine("");
                    }
                }
                LuaProfilerWindow.ClearConsole();
                Debug.Log(sb.ToString());
            }
            GUILayout.EndHorizontal();

            scrollPositionAdd = GUILayout.BeginScrollView(scrollPositionAdd, EditorStyles.helpBox, GUILayout.Height(100));
            foreach (var item in luaDiff.addRef)
            {
                DrawItemInfo(item.Key, item.Value.ToString(), luaDiff.addDetail);
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("rm values count:" + luaDiff.rmRef.Count, GUILayout.Width(150));
            if (GUILayout.Button("ShowLog", GUILayout.Width(100)))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("rm:");
                foreach (var item in luaDiff.rmRef)
                {
                    List <string> list  = null;
                    string        key   = item.Key;
                    string        value = item.Value.ToString();
                    if (luaDiff.rmDetail.TryGetValue(key, out list))
                    {
                        foreach (var itemx in list)
                        {
                            sb.Append("Key:");
                            sb.Append(itemx);
                            sb.Append(" ValueType:");
                            sb.AppendLine(value);
                        }
                        sb.AppendLine("");
                    }
                }
                LuaProfilerWindow.ClearConsole();
                Debug.Log(sb.ToString());
            }
            GUILayout.EndHorizontal();

            scrollPositionRm = GUILayout.BeginScrollView(scrollPositionRm, EditorStyles.helpBox, GUILayout.Height(100));
            foreach (var item in luaDiff.rmRef)
            {
                DrawItemInfo(item.Key, item.Value.ToString(), luaDiff.rmDetail);
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Destory null values count:" + luaDiff.nullRef.Count, GUILayout.Width(200));
            if (GUILayout.Button("ShowLog", GUILayout.Width(100)))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("null:");
                foreach (var item in luaDiff.nullRef)
                {
                    sb.AppendLine(item);
                }
                LuaProfilerWindow.ClearConsole();
                Debug.Log(sb.ToString());
            }
            GUILayout.EndHorizontal();

            scrollPositionNull = GUILayout.BeginScrollView(scrollPositionNull, EditorStyles.helpBox, GUILayout.Height(100));
            foreach (var item in luaDiff.nullRef)
            {
                GUILayout.Label(item);
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            #endregion

            #region detail
            scrollPositionDetail = GUILayout.BeginScrollView(scrollPositionDetail, EditorStyles.helpBox, GUILayout.Width(250));
            if (m_detailList != null)
            {
                foreach (var item in m_detailList)
                {
                    GUILayout.Label(item);
                }
            }
            GUILayout.EndScrollView();
            #endregion

            GUILayout.EndHorizontal();
        }