1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- const saveDom = document.querySelector('.save-image-backgroup');
- let isShowSaveDom = false;
- window.updateTexture = function (title, base64string) {
- saveDom.src = 'data:image/png;base64,' + base64string;
- isShowSaveDom = true;
- saveDom.style.pointerEvents = 'auto';
- refreshShareBlockSize();
- }
- window.gameInitialized = function () {
- }
- window.closeGame = function () {
- window.parent?.closeGame();
- }
- window.closePanel = function () {
- isShowSaveDom = false;
- saveDom.style.pointerEvents = 'none';
- }
- window.clickEdit = function () {
- window.parent?.isShowToastFromGame()
- }
- // 提供给父页面点击保存按钮使用
- window.saveTitle = function(msg) {
- window.unityInstance.SendMessage('WebEvent', 'UpdateTextureContent', msg)
- }
- function refreshShareBlockSize() {
- // Unity画布宽高比
- let unityCanvasWidth = 1560;
- let unityCanvaslHeight = 3376;
- let unityPanelWidth = 1450;
- let unityPanelHeight = 2800;
- let unityPanelOffsetY = -148;
- let innerWidth = window.innerWidth;
- let innerHeight = window.innerHeight;
- let scale = (unityCanvasWidth / unityPanelHeight) >
- (innerWidth / innerHeight) ? (innerWidth / unityCanvasWidth) : (innerHeight / unityCanvaslHeight);
-
- saveDom.style.width = (unityPanelWidth * scale) + 'px';
- saveDom.style.height = (unityPanelHeight * scale) + 'px';
-
- if (unityPanelOffsetY > 0){
- saveDom.style.marginTop = (unityPanelOffsetY * scale * 2) + 'px';
- } else {
- saveDom.style.marginBottom = (-unityPanelOffsetY * scale * 2) + 'px';
- }
- }
- window.addEventListener('resize', ()=>{
- if (isShowSaveDom) refreshShareBlockSize();
- });
|