Skip to content

fix:界面-窗口 添加可视化表现 #1008

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions Demo/API_V2/Assets/API/GUI/Window/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
public class Window : Details
{
private bool _isListening = false;
private float timer = 0f;
private float interval = 5f; // 定时器间隔

private readonly Action<OnWindowResizeListenerResult> _onWindowResize = (res) =>
{
Expand All @@ -33,6 +35,39 @@ protected override void TestAPI(string[] args)
);
}

private void Start()
{
// 绑定额外的按钮操作
GameManager.Instance.detailsController.BindExtraButtonAction(0, setDeviceOrientation);
}

private void Update()
{
if(timer >= 20f){
timer += Time.deltaTime; // 每帧累加时间
Debug.Log(timer);
}
if (timer >= interval + 20)
{
Debug.Log("定时器触发!");
WX.SetDeviceOrientation(new SetDeviceOrientationOption()
{
value = "portrait",
});
timer = 0f; // 重置计时器(如果是周期性触发则不需要重置)
}
}

private void setDeviceOrientation()
{
Debug.Log("设置为横屏");
WX.SetDeviceOrientation(new SetDeviceOrientationOption()
{
value = "landscape",
});

timer = 20f;
}
private void OnDestroy()
{
WX.OffWindowResize(_onWindowResize);
Expand Down
5 changes: 3 additions & 2 deletions Demo/API_V2/Assets/API/GUI/Window/WindowSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ MonoBehaviour:
entryName: "\u7A97\u53E3"
entryOrder: 0
entryScriptTypeName: Window
entryAPI: "onWindowResize \uFF5C offWindowResize"
entryAPI: "OnWindowResize \uFF5C OffWindowResize"
entryDescription:
optionList: []
initialButtonText: "\u5F00\u59CB\u76D1\u542C"
extraButtonList: []
extraButtonList:
- buttonText: "\u7A97\u53E3\u53D8\u6210\u6A2A\u5C4F(5s\u540E\u6062\u590D)"
initialResultList: []
Loading