chenxin
2020-12-03 513df7ede07913b22f3091fec5221e2bc2eadd74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using Core.Utilities;
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class ViewPortAdj : Singleton<ViewPortAdj>
{
    /// <summary>
    /// Cached camera component
    /// </summary>
    public UnityEngine.Camera cachedCamera { get; private set; }
 
    public UnityEngine.Camera backGroundCamera { get; private set; }
 
    public bool bAdjViewPort = false;
 
    public void DOShakePosition()
    {
        KTGMGemClient.GameConfig.IsShaking = true;
        cachedCamera.DOShakePosition(0.25f, 1.5f, 4).OnComplete(() =>
        {
            KTGMGemClient.GameConfig.IsShaking = false;
        });
        backGroundCamera.DOShakePosition(0.25f, 1.5f, 4);
    }
 
 
 
    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<UnityEngine.Camera>();
        backGroundCamera = GameObject.Find("BackCamera").GetComponent<UnityEngine.Camera>();
    }
 
    // 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;
    }
}