Files
2026-05-26 16:15:54 +08:00

47 lines
1.6 KiB
C#

using asap.core;
using GameCore;
using UnityEngine;
using UnityEngine.UI;
public class SurveyPanel : MonoBehaviour
{
Button btn_close;
RectTransform RectPos;
WebView webView;
int left; int top; int right; int bottom;
private void Awake()
{
webView = GetComponent<WebView>();
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
RectPos = transform.Find("content").GetComponent<RectTransform>();
}
private void Start()
{
UIManager.Instance.DestroyUI(UITypes.FishingMorePanel);
Vector2 anchoredPosition1 = GetComponent<RectTransform>().anchoredPosition;
Vector2 anchoredPosition = anchoredPosition1 + RectPos.anchoredPosition;
var rect = RectPos.rect;
var rectparent = UIManager.Instance.RectTrans.rect;
int width = (int)rectparent.width / 2;
int height = (int)rectparent.height / 2;
left = width + (int)(rect.xMin + anchoredPosition.x);
right = width - (int)(rect.xMax + anchoredPosition.x);
top = height - (int)(rect.yMax + anchoredPosition.y);
bottom = height + (int)(rect.yMin + anchoredPosition.y);
string Url = GContext.container.Resolve<SurveyService>().GetSurveyAnswer();
webView.OnOpen(Url, left, top, right, bottom);
btn_close.onClick.AddListener(Close);
}
void Close()
{
GContext.container.Resolve<SurveyService>().GetSurveyCheckAnswer();
UIManager.Instance.DestroyUI(UITypes.SurveyPanel);
}
private void OnDisable()
{
webView.OnClose();
}
}