当前位置: 首页 > news >正文

unity开发安卓视频文件适配手机和平板

using UnityEngine;
using UnityEngine.UI;public class VideoResize : MonoBehaviour
{private RawImage rawImage;private VideoPlayer videoPlayer;private void Start(){rawImage = GetComponent<RawImage();videoPlayer = GetComponent<VideoPlayer>();// 播放视频videoPlayer.Play();// 调整视频大小以适应屏幕ResizeVideo();}private void ResizeVideo(){int videoWidth = 1920;//视频的宽int videoHeight = 1080;//视频的高int targetWidth = Screen.width;//屏幕宽int targetHeight = Screen.height;//屏幕高float scaleWidth = (float)targetWidth / videoWidth;float scaleHeight = (float)targetHeight / videoHeight;// 确保保持原始宽高比float scaleFactor = Mathf.Min(scaleWidth, scaleHeight);int newWidth = Mathf.RoundToInt(videoWidth * scaleFactor);int newHeight = Mathf.RoundToInt(videoHeight * scaleFactor);rawImage.rectTransform.sizeDelta = new Vector2(newWidth , newHeight );}
}
http://www.lryc.cn/news/209222.html

相关文章:

  • NLP之RNN的原理讲解(python示例)
  • yo!这里是进程间通信
  • 使用docker安装MySQL,Redis,Nacos,Consul教程
  • python和Springboot如何交互?
  • Qt实现json解析
  • Ajax、Json深入浅出,及原生Ajax及简化版Ajax
  • 前端第一阶段测试
  • openlayers+vue的bug
  • 实时数仓-Hologres介绍与架构
  • asp.net教务管理信息系统VS开发sqlserver数据库web结构c#编程Microsoft Visual Studio计算机毕业设计
  • 爬虫、数据清洗和分析
  • SpringBoot | SpringBoot中实现“微信支付“
  • 基于SSM和VUE的留守儿童信息管理系统
  • VMware 16开启虚拟机电脑就蓝屏W11解决方法
  • 【Bug——VMware Workstation】虚拟机桥接网络没有 VMnet0
  • centos中安装Mysql8.0
  • 简化对象和函数写法
  • GB/T28181流媒体相关协议详解
  • 十进制转二进制的算法代码 ← Python
  • 智慧垃圾站:AI视频智能识别技术助力智慧环保项目,以“智”替人强监管
  • LeetCode 面试题 16.07. 最大数值
  • PS 安装教程 2022版(全网最详细图文教程)
  • [Python] OSError: [E050] Can‘t find model ‘en_core_web_sm‘.
  • 集合总结(Java)
  • 【ONE·Linux || 网络基础(一)】
  • Day12力扣打卡
  • SQL注入原理及思路(mysql)
  • vue核心面试题汇总【查缺补漏】
  • 使用WebStorm创建和配置TypeScript项目
  • vue源码分析(四)——vue 挂载($mount)的详细过程