MediaPlayerFullScreenCtrl.cs 740 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. using System.Collections;
  3. public class MediaPlayerFullScreenCtrl : MonoBehaviour {
  4. public GameObject m_objVideo;
  5. int m_iOrgWidth = 0;
  6. int m_iOrgHeight = 0;
  7. // Use this for initialization
  8. void Start () {
  9. Resize ();
  10. }
  11. // Update is called once per frame
  12. void Update () {
  13. if( m_iOrgWidth != Screen.width)
  14. Resize();
  15. if( m_iOrgHeight != Screen.height)
  16. Resize();
  17. }
  18. void Resize()
  19. {
  20. m_iOrgWidth = Screen.width;
  21. m_iOrgHeight = Screen.height;
  22. float fRatio = (float) m_iOrgHeight / (float)m_iOrgWidth;
  23. m_objVideo.transform.localScale = new Vector3( 20.0f / fRatio, 20.0f / fRatio, 1.0f);
  24. m_objVideo.transform.GetComponent<MediaPlayerCtrl>().Resize();
  25. }
  26. }