12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class LogoZoom : MonoBehaviour
- {
- public bool isDark=true;
- GameObject logo;
- public Sprite darkSp;
- ScreenOrientation orientation;
- int width = Screen.width;
- void Start()
- {
-
- orientation = Screen.orientation;
- logo= GameObject.Find("PottingLogo");
- if (isDark) {
- Image bg = GameObject.Find("PottingBg").GetComponent<Image>();
- logo.GetComponent<Image>().sprite = darkSp;
- bg.color = new Color((18 / 255f), (18 / 255f), (18/ 255f), (255 / 255f));
- }
- if (orientation == ScreenOrientation.LandscapeLeft) {
- width = Screen.height;
- }
- Zoom();
- Invoke("NextScene", 3f);
- }
- void Zoom()
- {
-
- if (orientation == ScreenOrientation.Portrait || orientation == ScreenOrientation.PortraitUpsideDown)
- {
- float logow = width / 3;
- float zoom = 1.4238f;
- float logoh = logow / zoom;
- logo.transform.GetComponent<RectTransform>().sizeDelta = new Vector2(logow, logoh);
- }
- else
- {
- float logoh = width / 5;
- float zoom = 1.4238f;
- float logow = logoh * zoom;
- logo.transform.GetComponent<RectTransform>().sizeDelta = new Vector2(logow, logoh);
- }
- }
- /// <summary>
- /// 加载游戏场景
- /// </summary>
- void NextScene() {
- SceneManager.LoadScene("PottingMobScene");
- }
- // Update is called once per frame
- void Update()
- {
- if (orientation!= Screen.orientation) {
- orientation = Screen.orientation;
- Zoom();
- }
- }
- }
|