2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using UnityEngine ;
5
+ using UnityEngine . Diagnostics ;
5
6
6
7
namespace UniDebugMenu . Example
7
8
{
@@ -11,6 +12,33 @@ namespace UniDebugMenu.Example
11
12
[ Serializable ]
12
13
public sealed class iOSCrashReportListCreator : ListCreatorBase < ActionData >
13
14
{
15
+ //==============================================================================
16
+ // 定数(static readonly)
17
+ //==============================================================================
18
+ private static readonly string NL = Environment . NewLine ;
19
+ private static readonly string TIME_FORMAT = "yyyy/MM/dd HH:mm:ss" ;
20
+
21
+ //==============================================================================
22
+ // クラス
23
+ //==============================================================================
24
+ private sealed class CrashData
25
+ {
26
+ public readonly string m_time ;
27
+ public readonly string m_summary ;
28
+ public readonly string m_text ;
29
+ public readonly string m_listText ;
30
+ public readonly string m_detailText ;
31
+
32
+ public CrashData ( CrashReport report )
33
+ {
34
+ m_time = report . time . ToString ( TIME_FORMAT ) ;
35
+ m_summary = report . text . Split ( new [ ] { NL } , StringSplitOptions . None ) . FirstOrDefault ( ) ;
36
+ m_text = report . text ;
37
+ m_listText = $ "{ m_time } : { m_summary } ";
38
+ m_detailText = $ "{ m_time } { NL } { NL } { NL } { m_text } ";
39
+ }
40
+ }
41
+
14
42
//==============================================================================
15
43
// 変数
16
44
//==============================================================================
@@ -21,6 +49,12 @@ public sealed class iOSCrashReportListCreator : ListCreatorBase<ActionData>
21
49
//==============================================================================
22
50
public override int Count => m_list . Count ;
23
51
52
+ public override ActionData [ ] OptionActionList => new [ ]
53
+ {
54
+ new ActionData ( "テスト" , ( ) => Utils . ForceCrash ( ForcedCrashCategory . AccessViolation ) ) ,
55
+ new ActionData ( "削除" , ( ) => { CrashReport . RemoveAll ( ) ; UpdateDisp ( ) ; } ) ,
56
+ } ;
57
+
24
58
//==============================================================================
25
59
// 関数
26
60
//==============================================================================
@@ -29,10 +63,12 @@ public sealed class iOSCrashReportListCreator : ListCreatorBase<ActionData>
29
63
/// </summary>
30
64
protected override void DoCreate ( ListCreateData data )
31
65
{
32
- m_list = ToText ( )
33
- . Split ( '\n ' )
34
- . Where ( c => data . IsMatch ( c ) )
35
- . Select ( c => new ActionData ( c ) )
66
+ m_list = CrashReport . reports
67
+ . Take ( CrashReport . reports . Length - 1 ) // 末尾のレポートが重複していたので無視
68
+ . OrderByDescending ( c => c . time )
69
+ . Select ( c => new CrashData ( c ) )
70
+ . Where ( c => data . IsMatch ( c . m_time , c . m_summary ) )
71
+ . Select ( c => new ActionData ( c . m_listText , ( ) => OpenAdd ( DMType . TEXT_TAB_6 , new SimpleTextListDataCreator ( c . m_detailText ) ) ) )
36
72
. ToArray ( )
37
73
. ReverseIf ( data . IsReverse )
38
74
;
@@ -42,17 +78,5 @@ protected override void DoCreate( ListCreateData data )
42
78
/// 指定されたインデックスの要素の表示に使用するデータを返します
43
79
/// </summary>
44
80
protected override ActionData DoGetElemData ( int index ) => m_list . ElementAtOrDefault ( index ) ;
45
-
46
- /// <summary>
47
- /// テキストを整形して返します
48
- /// </summary>
49
- private static string ToText ( )
50
- {
51
- var reports = CrashReport . reports ;
52
- var texts = reports . Select ( c => $ "{ c . time . ToString ( ) } : { c . text } " ) ;
53
- var result = string . Join ( "\n " , texts ) ;
54
-
55
- return result ;
56
- }
57
81
}
58
82
}
0 commit comments