[=]SafeTop ImageBackGround

[=]SafeTop ImageBackGround
This commit is contained in:
ALEXTANG
2023-05-09 14:34:14 +08:00
parent edc83c8989
commit 079ff980a3
4 changed files with 37 additions and 3 deletions

View File

@@ -1,30 +0,0 @@
using UnityEngine;
namespace GameLogic
{
/// <summary>
/// 背景图片等比拉伸
/// </summary>
public class ImageBackGroundStretch : MonoBehaviour
{
protected virtual void Start()
{
DoImageStretch(9/16f);
}
private void DoImageStretch(float standardAspect)
{
float deviceAspect = Screen.width / (float)Screen.height;
if (standardAspect > deviceAspect)
{
float scale = standardAspect / deviceAspect;
transform.localScale = new Vector3(scale, scale, 1f);
}
else if (standardAspect < deviceAspect)
{
float scale = deviceAspect / standardAspect;
transform.localScale = new Vector3(scale, scale, 1f);
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 4e6e63472f81d39499f4bf79b27eaf44
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c0a563c3e931db74f94f9991270a2dee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: