5
5
6
6
public class ToTempFilePath : Details
7
7
{
8
+ private void Start ( )
9
+ {
10
+ LogCurrentOptions ( ) ;
11
+ }
12
+
8
13
protected override void TestAPI ( string [ ] args )
9
14
{
15
+ LogCurrentOptions ( ) ; // 执行API前打印当前值
10
16
LoadCanvasToTempFilePath ( ) ;
11
17
}
12
18
19
+ /// <summary>
20
+ /// 当下拉菜单值改变时的回调方法
21
+ /// </summary>
22
+ /// <param name="dropdownIndex">下拉菜单索引</param>
23
+ /// <param name="optionIndex">选项索引</param>
24
+ public new void OnDropdownValueChanged ( int dropdownIndex , int optionIndex )
25
+ {
26
+ base . OnDropdownValueChanged ( dropdownIndex , optionIndex ) ;
27
+ string newValue = entrySO . optionList [ dropdownIndex ] . availableOptions [ optionIndex ] ;
28
+ UpdateOption ( dropdownIndex , newValue ) ;
29
+ LogCurrentOptions ( ) ;
30
+ }
31
+
32
+
33
+ private float GetOptionValue ( int optionIndex , float defaultValue = 0f )
34
+ {
35
+ if ( options != null && optionIndex < options . Length )
36
+ {
37
+ if ( float . TryParse ( options [ optionIndex ] , out float value ) )
38
+ {
39
+ return value ;
40
+ }
41
+ }
42
+ return defaultValue ;
43
+ }
44
+
13
45
private void LoadCanvasToTempFilePath ( )
14
46
{
15
- var sys = WX . GetSystemInfoSync ( ) ;
47
+ var sys = WX . GetSystemInfoSync ( ) ;
16
48
string sysInfo = string . Format (
17
49
"屏幕信息:\n screenWidth:{0}\n screenHeight:{1}\n windowWidth:{2}\n windowHeight:{3}\n " ,
18
50
sys . screenWidth , sys . screenHeight , sys . windowWidth , sys . windowHeight
19
51
) ;
20
52
21
-
53
+ // 根据options数组的索引获取值
54
+ float x = GetOptionValue ( 0 ) ;
55
+ float y = GetOptionValue ( 1 ) ;
56
+ float width = GetOptionValue ( 2 ) ;
57
+ float height = GetOptionValue ( 3 ) ;
58
+
59
+ Debug . Log ( $ "Using values: x={ x } , y={ y } , width={ width } , height={ height } ") ;
60
+
22
61
WXCanvas . ToTempFilePath ( new WXToTempFilePathParam ( )
23
62
{
63
+ x = ( int ) x ,
64
+ y = ( int ) y ,
65
+ width = ( int ) width ,
66
+ height = ( int ) height ,
24
67
success = ( result ) =>
25
68
{
26
69
WX . ShowModal ( new ShowModalOption ( )
@@ -49,8 +92,48 @@ private void LoadCanvasToTempFilePath()
49
92
} ,
50
93
complete = ( result ) =>
51
94
{
52
- //完成处理
95
+ Debug . Log ( "complete" ) ;
53
96
} ,
54
97
} ) ;
55
98
}
99
+
100
+ // 打印当前选项的值
101
+ private void LogCurrentOptions ( )
102
+ {
103
+ if ( options != null )
104
+ {
105
+ for ( int i = 0 ; i < options . Length ; i ++ )
106
+ {
107
+ Debug . Log ( $ "Option { i } : { options [ i ] } ") ;
108
+ }
109
+ }
110
+ else
111
+ {
112
+ Debug . Log ( "Options array is null" ) ;
113
+ }
114
+ }
115
+
116
+ // 更新指定索引的选项值
117
+ public void UpdateOption ( int optionIndex , string value )
118
+ {
119
+ if ( options != null && optionIndex < options . Length )
120
+ {
121
+ options [ optionIndex ] = value ;
122
+ }
123
+ else
124
+ {
125
+ Debug . Log ( $ "Cannot update option { optionIndex } : Invalid index or options not initialized") ;
126
+ }
127
+ }
128
+
129
+ // 更新所有选项值
130
+ public void UpdateValues ( )
131
+ {
132
+ // 直接从entrySO中获取值并更新
133
+ for ( int i = 0 ; i < entrySO . optionList . Count ; i ++ )
134
+ {
135
+ string value = entrySO . optionList [ i ] . availableOptions [ 0 ] ;
136
+ UpdateOption ( i , value ) ; // 更新对应索引选项值
137
+ }
138
+ }
56
139
}
0 commit comments