123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class UIBGP : MonoBehaviour
- {
- public GameObject topGame;
- public bool isCenter=false;
- Vector3 initV3;
-
- void Awake()
- {
- initV3 = this.GetComponent<RectTransform>().anchoredPosition;
- }
-
- void Update()
- {
- if(topGame)
- {
- initV3 = new Vector3(initV3.x,-topGame.GetComponent<RectTransform>().sizeDelta.y,initV3.z);
- }
- float bl = (float)Screen.width / 430f;
- float bl2 = (float)Screen.height / 932f;
- if(bl>bl2)
- {
- this.transform.localScale = new Vector3(bl2,bl2,bl2);
- }else
- {
- this.transform.localScale = new Vector3(bl, bl, bl);
- }
-
- this.GetComponent<RectTransform>().anchoredPosition= new Vector2(initV3.x,initV3.y* this.transform.localScale.x);
-
- if(isCenter)
- {
- this.GetComponent<RectTransform>().sizeDelta =new Vector2(430, ((float)Screen.height - (-this.GetComponent<RectTransform>().anchoredPosition.y+100*this.transform.localScale.x))/this.transform.localScale.x);
- }
- }
- }
|