using Core.Utilities; using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ViewPortAdj : Singleton { /// /// Cached camera component /// public UnityEngine.Camera cachedCamera { get; private set; } private Vector3 cachedCameraPos; public UnityEngine.Camera backGroundCamera { get; private set; } private Vector3 backGroundCameraPos; public bool bAdjViewPort = false; public void DOShakePosition() { KTGMGemClient.GameConfig.IsShaking = true; cachedCamera.DOShakePosition(0.25f, 1.5f, 4).OnComplete(() => { KTGMGemClient.GameConfig.IsShaking = false; cachedCamera.transform.position = cachedCameraPos; }); backGroundCamera.DOShakePosition(0.25f, 1.5f, 4).OnComplete(() => { backGroundCamera.transform.position = backGroundCameraPos; }); } public void adjViewportRect() { //float wscale = 1080f/Screen.width; //// River: 动态的处理ViewPortRect. //float vpscale = (1920f / wscale / Screen.height); //Rect vpRect = new Rect(); //vpRect.x = 0.0f; //vpRect.y = (1.0f - vpscale) / 2.0f; //vpRect.width = 1f; //vpRect.height = vpscale; //cachedCamera.rect = vpRect; //bAdjViewPort = true; } protected override void Awake() { base.Awake(); cachedCamera = GetComponent(); backGroundCamera = GameObject.Find("BackCamera").GetComponent(); cachedCameraPos = cachedCamera.transform.position; backGroundCameraPos = backGroundCamera.transform.position; } // Start is called before the first frame update void Start() { // 初始化的时候调整视口就OK了. this.adjViewportRect(); Application.targetFrameRate = 60; } // Update is called once per frame void Update() { //this.adjViewportRect(); //Application.targetFrameRate = 60; } }