Skip to content

Canvas #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Demo/API_V2/Assets/API/APISO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 9977a581037b84833a32b508e00eb1a2, type: 2}
- {fileID: 11400000, guid: 56f316e0e10ba419bbf19bd7a68bfc4c, type: 2}
- {fileID: 11400000, guid: 6f0972f5fdc56c543b23c9873d760bf5, type: 2}
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
- {fileID: 11400000, guid: 55de20d536f8c4689bbd80553d87fe46, type: 2}
- {fileID: 11400000, guid: f2c56d751bb7c4c398db7c1db352517d, type: 2}
- {fileID: 11400000, guid: b4a6196f623dd4435a4f3bd70af92d06, type: 2}
Expand Down
4 changes: 2 additions & 2 deletions Demo/API_V2/Assets/API/Facility/FacilitySO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ MonoBehaviour:
categoryName: "\u8BBE\u5907"
categorySprite: {fileID: 21300000, guid: 53dd2b1922e5142ec8a53037f362fc56, type: 3}
entryList:
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
- {fileID: 11400000, guid: ac09abff5d8bc48bbabd08bde820b58b, type: 2}
- {fileID: 11400000, guid: 3bf339b994c544db3860ddf0a0dc8e20, type: 2}
- {fileID: 11400000, guid: e92d94924be504167a342e42e1162f21, type: 2}
Expand Down
1 change: 1 addition & 0 deletions Demo/API_V2/Assets/API/Facility/Screen/ScreenSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ MonoBehaviour:
- buttonText: "\u67E5\u8BE2\u7528\u6237\u662F\u5426\u5728\u5F55\u5C4F"
- buttonText: "\u83B7\u53D6\u5C4F\u5E55\u4EAE\u5EA6"
initialResultList: []
entryOrder: 0
2 changes: 1 addition & 1 deletion Demo/API_V2/Assets/API/FileSystem/FileSystemSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 65ab1b01a722b4542a14fcf9decca3de, type: 2}
- {fileID: 11400000, guid: 19b80cb144f0c4ea28a4ddca7a2c2f09, type: 2}
- {fileID: 11400000, guid: 0aa5d76237c844275add1612c47bddaa, type: 2}
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
- {fileID: 11400000, guid: 3a901e80b59ad4aafbe373ee6a8df2d8, type: 2}
- {fileID: 11400000, guid: e7ea0be62dc6543b0a8dc629489c5e7e, type: 2}
categoryOrder: 11
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ MonoBehaviour:
- buttonText: "\u8DF3\u8F6C"
- buttonText: "\u83B7\u5F97\u4E0B\u4E00\u5E27"
initialResultList: []
entryOrder: 0
1 change: 1 addition & 0 deletions Demo/API_V2/Assets/API/Render/RenderSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ MonoBehaviour:
entryList:
- {fileID: 11400000, guid: 3742edf3f50854504ba8632134064e94, type: 2}
- {fileID: 11400000, guid: c185ac653050d49608ea734a26e8dbaa, type: 2}
- {fileID: 11400000, guid: f9a70ffa3b7f4db40b550f6b153c4ed2, type: 2}
categoryOrder: 8
8 changes: 8 additions & 0 deletions Demo/API_V2/Assets/API/Render/ToTempFilePath.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions Demo/API_V2/Assets/API/Render/ToTempFilePath/ToTempFilePath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WeChatWASM;
using LitJson;

public class ToTempFilePath : Details
{
protected override void TestAPI(string[] args)
{
if (args[0] == "同步执行")
{
LoadCanvasToTempFilePathSync();
}
else
{
LoadCanvasToTempFilePath();
}
}

// 异步
private void LoadCanvasToTempFilePath()
{// 根据options数组的索引获取值
float x = GetOptionValue(1);
float y = GetOptionValue(2);
float width = GetOptionValue(3);
float height = GetOptionValue(4);
float destWidth = GetOptionValue(5);
float destHeight = GetOptionValue(6);
string fileType = GetOptionString(7, "png");
float quality = GetOptionValue(8);

string optionsInfo = $"当前参数值:\nx={x}\ny={y}\nwidth={width}\nheight={height}\ndestWidth={destWidth}\ndestHeight={destHeight}\nfileType={fileType}\nquality={quality}";

WXCanvas.ToTempFilePath(new WXToTempFilePathParam()
{
x = (int)x,
y = (int)y,
width = (int)width,
height = (int)height,
destWidth = (int)destWidth,
destHeight = (int)destHeight,
fileType = fileType,
quality = (int)quality,

success = (result) =>
{
WX.ShowModal(new ShowModalOption()
{
title = "截图成功(异步)",
content = $"{optionsInfo}\n\n临时文件路径:\n{result.tempFilePath}",
showCancel = false,
confirmText = "展示截图",
success = (res) =>
{
WX.PreviewMedia(new PreviewMediaOption()
{
sources = new[] { new MediaSource { url = result.tempFilePath, type = "image" } },
current = 0,
success = (res) =>
{
Debug.Log("预览成功");
},
fail = (res) =>
{
Debug.Log("预览失败");
}
});
}
});
},
fail = (result) =>
{
WX.ShowModal(new ShowModalOption()
{
title = "截图失败",
content = JsonUtility.ToJson(result),
showCancel = false
});
},
complete = (result) =>
{
Debug.Log("complete");
},
});
}

// 同步
private void LoadCanvasToTempFilePathSync()
{

// 根据options数组的索引获取值
float x = GetOptionValue(1);
float y = GetOptionValue(2);
float width = GetOptionValue(3);
float height = GetOptionValue(4);
float destWidth = GetOptionValue(5);
float destHeight = GetOptionValue(6);
string fileType = GetOptionString(7, "png");
float quality = GetOptionValue(8);

string optionsInfo = $"当前参数值:\nx={x}\ny={y}\nwidth={width}\nheight={height}\ndestWidth={destWidth}\ndestHeight={destHeight}\nfileType={fileType}\nquality={quality}";

var tempFilePath = WXCanvas.ToTempFilePathSync(new WXToTempFilePathSyncParam()
{
x = (int)x,
y = (int)y,
width = (int)width,
height = (int)height,
destWidth = (int)destWidth,
destHeight = (int)destHeight,
fileType = fileType,
quality = (int)quality,
});
// 显示同步访问的结果
WX.ShowModal(new ShowModalOption()
{
title = "截图成功(同步)",
content = $"{optionsInfo}\n\n临时文件路径:\n{tempFilePath}",
showCancel = false,
confirmText = "展示截图",
success = (res) =>
{
WX.PreviewMedia(new PreviewMediaOption()
{
sources = new[] { new MediaSource { url = tempFilePath, type = "image" } },
current = 0,
success = (res) =>
{
Debug.Log("预览成功");
},
fail = (res) =>
{
Debug.Log("预览失败");
}
});
}
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fb48e4613a53bb941a20036d7c08fefb, type: 3}
m_Name: ToTempFilePathSO
m_EditorClassIdentifier:
entryScriptTypeName: ToTempFilePath
entryName: "\u622A\u5C4F"
entryAPI: Canvas.toTempFilePath
entryDescription: "\u5C06\u5F53\u524D Canvas \u4FDD\u5B58\u4E3A\u4E00\u4E2A\u4E34\u65F6\u6587\u4EF6\u3002"
optionList:
- optionName: "\u6267\u884C\u65B9\u5F0F"
availableOptions:
- "\u540C\u6B65\u6267\u884C"
- "\u5F02\u6B65\u6267\u884C"
- optionName: x
availableOptions:
- 0
- 500
- optionName: y
availableOptions:
- 0
- 500
- optionName: width
availableOptions:
- 0
- 400
- optionName: height
availableOptions:
- 0
- 800
- optionName: destWidth
availableOptions:
- 0
- 800
- optionName: destHeight
availableOptions:
- 0
- 800
- optionName: fileType
availableOptions:
- png
- jpg
- optionName: quality
availableOptions:
- 1.0
initialButtonText: "\u8FD0\u884C\u622A\u56FE"
extraButtonList: []
initialResultList: []
entryOrder: 0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ MonoBehaviour:
initialButtonText: "\u4E8B\u4EF6\u4E0A\u62A5"
extraButtonList: []
initialResultList: []
entryOrder: 0
1 change: 1 addition & 0 deletions Demo/API_V2/Assets/API/Share/ShareEvent/ShareEventSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ MonoBehaviour:
- buttonText: "\u76D1\u542Csharetofriend"
- buttonText: "\u76D1\u542C\u53F3\u4E0A\u89D2\u83DC\u5355\u7684\u8F6C\u53D1"
initialResultList: []
entryOrder: 0
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ MonoBehaviour:
- buttonText: "\u83B7\u53D6\u8F6C\u53D1\u8BE6\u7EC6\u4FE1\u606F"
- buttonText: "\u9A8C\u8BC1\u79C1\u5BC6\u6D88\u606F"
initialResultList: []
entryOrder: 0
Loading
Loading