Skip to content

Commit f77b23d

Browse files
committed
调整条目为截屏
1 parent 932502a commit f77b23d

File tree

5 files changed

+66
-97
lines changed

5 files changed

+66
-97
lines changed

Demo/API_V2/Assets/API/Media/VideoDecoder/VideoDecoderSO.asset

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ MonoBehaviour:
2323
- buttonText: "\u8DF3\u8F6C"
2424
- buttonText: "\u83B7\u5F97\u4E0B\u4E00\u5E27"
2525
initialResultList: []
26+
entryOrder: 0

Demo/API_V2/Assets/API/Render/ToTempFilePath/ToTempFilePath.cs

+27-95
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,12 @@
55

66
public class ToTempFilePath : Details
77
{
8-
private void Start()
9-
{
10-
LogCurrentOptions();
11-
}
12-
138
protected override void TestAPI(string[] args)
149
{
15-
LogCurrentOptions(); // 执行API前打印当前值
1610
LoadCanvasToTempFilePath();
1711
}
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-
45-
private string GetOptionString(int optionIndex, string defaultValue = "")
46-
{
47-
if (options != null && optionIndex < options.Length)
48-
{
49-
return options[optionIndex];
50-
}
51-
return defaultValue;
52-
}
53-
5412
private void LoadCanvasToTempFilePath()
55-
{
56-
var sys = WX.GetSystemInfoSync();
57-
string sysInfo = string.Format(
58-
"屏幕信息:\nscreenWidth:{0}\nscreenHeight:{1}\nwindowWidth:{2}\nwindowHeight:{3}\n",
59-
sys.screenWidth, sys.screenHeight, sys.windowWidth, sys.windowHeight
60-
);
61-
62-
// 根据options数组的索引获取值
13+
{// 根据options数组的索引获取值
6314
float x = GetOptionValue(0);
6415
float y = GetOptionValue(1);
6516
float width = GetOptionValue(2);
@@ -69,7 +20,7 @@ private void LoadCanvasToTempFilePath()
6920
string fileType = GetOptionString(6, "png");
7021
float quality = GetOptionValue(7);
7122

72-
Debug.Log($"Using values: x={x}, y={y}, width={width}, height={height}, destWidth={destWidth}, destHeight={destHeight}, fileType={fileType}, quality={quality}");
23+
string optionsInfo = $"当前参数值:\nx={x}\ny={y}\nwidth={width}\nheight={height}\ndestWidth={destWidth}\ndestHeight={destHeight}\nfileType={fileType}\nquality={quality}";
7324

7425
WXCanvas.ToTempFilePath(new WXToTempFilePathParam()
7526
{
@@ -87,14 +38,35 @@ private void LoadCanvasToTempFilePath()
8738
WX.ShowModal(new ShowModalOption()
8839
{
8940
title = "截图成功",
90-
content = "临时文件路径:" + result.tempFilePath + "\n\n" + sysInfo,
41+
content = $"{optionsInfo}\n\n临时文件路径:{result.tempFilePath}",
9142
showCancel = false,
9243
success = (res) =>
9344
{
94-
WX.ShareAppMessage(new ShareAppMessageOption()
45+
WX.PreviewMedia(new PreviewMediaOption()
46+
{
47+
sources = new[] { new MediaSource { url = result.tempFilePath, type = "image" } },
48+
current = 0,
49+
success = (res) =>
50+
{
51+
Debug.Log("预览成功");
52+
},
53+
fail = (res) =>
54+
{
55+
Debug.Log("预览失败");
56+
}
57+
});
58+
var fileManager = WX.GetFileSystemManager();
59+
fileManager.Access(new AccessParam()
9560
{
96-
title = "这是你的标题",
97-
imageUrl = result.tempFilePath,
61+
path = result.tempFilePath,
62+
success = (res) =>
63+
{
64+
Debug.Log("文件存在");
65+
},
66+
fail = (res) =>
67+
{
68+
Debug.Log("文件不存在");
69+
}
9870
});
9971
}
10072
});
@@ -114,44 +86,4 @@ private void LoadCanvasToTempFilePath()
11486
},
11587
});
11688
}
117-
118-
// 打印当前选项的值
119-
private void LogCurrentOptions()
120-
{
121-
if (options != null)
122-
{
123-
for (int i = 0; i < options.Length; i++)
124-
{
125-
Debug.Log($"Option {i}: {options[i]}");
126-
}
127-
}
128-
else
129-
{
130-
Debug.Log("Options array is null");
131-
}
132-
}
133-
134-
// 更新指定索引的选项值
135-
public void UpdateOption(int optionIndex, string value)
136-
{
137-
if (options != null && optionIndex < options.Length)
138-
{
139-
options[optionIndex] = value;
140-
}
141-
else
142-
{
143-
Debug.Log($"Cannot update option {optionIndex}: Invalid index or options not initialized");
144-
}
145-
}
146-
147-
// 更新所有选项值
148-
public void UpdateValues()
149-
{
150-
// 直接从entrySO中获取值并更新
151-
for (int i = 0; i < entrySO.optionList.Count; i++)
152-
{
153-
string value = entrySO.optionList[i].availableOptions[0];
154-
UpdateOption(i, value); // 更新对应索引选项值
155-
}
156-
}
15789
}

Demo/API_V2/Assets/API/Render/ToTempFilePath/ToTempFilePathSO.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MonoBehaviour:
1313
m_Name: ToTempFilePathSO
1414
m_EditorClassIdentifier:
1515
entryScriptTypeName: ToTempFilePath
16-
entryName: "\u753B\u5E03"
16+
entryName: "\u622A\u5C4F"
1717
entryAPI: Canvas.toTempFilePath
1818
entryDescription: "\u5C06\u5F53\u524D Canvas \u4FDD\u5B58\u4E3A\u4E00\u4E2A\u4E34\u65F6\u6587\u4EF6\u3002"
1919
optionList:

Demo/API_V2/Assets/Scenes/MainScene.unity

+1-1
Original file line numberDiff line numberDiff line change
@@ -17914,7 +17914,7 @@ GameObject:
1791417914
- component: {fileID: 848500031}
1791517915
- component: {fileID: 848500030}
1791617916
m_Layer: 5
17917-
m_Name: "\u753B\u5E03"
17917+
m_Name: "\u622A\u5C4F"
1791817918
m_TagString: Untagged
1791917919
m_Icon: {fileID: 0}
1792017920
m_NavMeshLayer: 0

Demo/API_V2/Assets/Scripts/Details.cs

+36
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,40 @@ public void Run()
3434

3535
// 抽象方法,由子类实现具体的测试 API 逻辑
3636
protected abstract void TestAPI(string[] args);
37+
38+
protected float GetOptionValue(int optionIndex, float defaultValue = 0f)
39+
{
40+
if (options != null && optionIndex < options.Length)
41+
{
42+
if (float.TryParse(options[optionIndex], out float value))
43+
{
44+
return value;
45+
}
46+
}
47+
return defaultValue;
48+
}
49+
//获得选项String类型值
50+
protected string GetOptionString(int optionIndex, string defaultValue = "")
51+
{
52+
if (options != null && optionIndex < options.Length)
53+
{
54+
return options[optionIndex];
55+
}
56+
return defaultValue;
57+
}
58+
// 打印当前选项的值
59+
protected void LogCurrentOptions()
60+
{
61+
if (options != null)
62+
{
63+
for (int i = 0; i < options.Length; i++)
64+
{
65+
Debug.Log($"Option {i}: {options[i]}");
66+
}
67+
}
68+
else
69+
{
70+
Debug.Log("Options array is null");
71+
}
72+
}
3773
}

0 commit comments

Comments
 (0)