public override void OnInspectorGUI() { FrameRecorder script = (FrameRecorder)target; EditorGUILayout.LabelField("current frames: " + script.frameData.Count); EditorGUILayout.LabelField("histories:"); for (int i = 0; i < script.histories.Count; ++i) { EditorGUILayout.LabelField(string.Format("[{0}] frames: {1}", i, script.histories[i].Count)); } foldoutFrames = EditorGUILayout.Foldout(foldoutFrames, "frame objects " + script.objects.Count); if (foldoutFrames) { foreach (var frame in script.objects) { if (frame is MonoBehaviour) { EditorGUILayout.ObjectField((MonoBehaviour)frame, frame.GetType(), false); } else { EditorGUILayout.LabelField(frame.GetType().Name); } } } }
void CompareHistories(FrameRecorder recorder) { var histories = recorder.histories; var frameData = recorder.frameData; StringBuilder log = new StringBuilder(1024 * 1024); int processed = 0; int total = Total(histories); bool allGood = true; for (int i = histories.Count - 1; i >= 0; --i) { List <List <FrameRecorder.FrameData> > older = histories[i]; List <List <FrameRecorder.FrameData> > newer = i > 0 ? histories[i - 1] : frameData; int frameCount = Mathf.Min(older.Count, newer.Count); bool good = true; for (int j = 0; j < frameCount; ++j) { List <FrameRecorder.FrameData> olderList = older[j]; List <FrameRecorder.FrameData> newerList = newer[j]; if (olderList.Count != newerList.Count) { good &= false; log.AppendFormat( "[{0}->{1}, frame {2}]: frame data list count not equal\n", i, i > 0 ? (i - 1).ToString() : "current", j); continue; } for (int k = 0; k < olderList.Count; ++k, ++processed) { FrameRecorder.FrameData ofd = olderList[k]; FrameRecorder.FrameData nfd = newerList.Find(v => v.frameObj == ofd.frameObj); EditorUtility.DisplayCancelableProgressBar( "compare histories", string.Format("working...{0}/{1},{2}/{3},{4}/{5}", histories.Count - i - 1, histories.Count, j, frameCount, k, olderList.Count), (float)processed / total); if (null == nfd) { good &= false; log.AppendFormat( "[{0}->{1}, frame {2}]: {3} is not found in newer list\n", i, i > 0 ? (i - 1).ToString() : "current", j, ofd.frameObj.identity); continue; } string detail; if (!ofd.frameData.Compare(nfd.frameData, out detail)) { good &= false; log.AppendFormat( "[{0}->{1}, frame {2}]: {3}'s frame data[{4}] error: {5}\n", i, i > 0 ? (i - 1).ToString() : "current", j, ofd.frameObj.identity, ofd.frameData.GetType().Name, detail); } } } allGood &= good; } string logPath = Application.dataPath + "/../compare_histories.log"; if (File.Exists(logPath)) { File.Delete(logPath); } if (log.Length > 0) { File.WriteAllText(logPath, log.ToString(), Encoding.UTF8); } Debug.LogFormat("All Done: <b><color={0}>{1}</color></b>, view log at {2}", allGood ? "green" : "red", allGood, logPath); }