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

u3d加载外部视屏

u3d的外部加载视屏,采用www方式,可以使用gui播放,也可以绑定到gameobject上作为动态材质使用,不过目前只支持。ogg格式,需要转。。。

using UnityEngine;
using System.Collections;

public class movie : MonoBehaviour
{
    private MovieTexture movTexture;

    private string movPath;

    void Start()
    {
        movPath = "file://" + Application.dataPath + "/1.ogg";
        StartCoroutine(LoadMoview());

    }
    public void LoadRes()
    {
        movPath = "file://" + Application.dataPath + "/1.ogg";
        StartCoroutine(LoadMoview());
    }
    IEnumerator LoadMoview()
    {
        WWW wwwDate = new WWW(movPath);

        yield return wwwDate;
        movTexture = wwwDate.movie;//得到下载的贴图
        movTexture.loop = true;
        movTexture.Play();
    }

    // Update is called once per frame
    void Update()
    {
        // GUI.DrawTexture(new Rect(0 + 100, 0 + 100, Screen.width - 100, Screen.height - 100), movTexture, ScaleMode.ScaleToFit);
        


        this.renderer.material.mainTexture = movTexture;  
    }

    void OnGUI()
    {
     
       
    }
}


 下面是给一个gameobject加上这个脚本

using UnityEngine;
using System.Collections;

public class Init : MonoBehaviour
{
    private GameObject m_ObjCube;
    // Use this for initialization
    void Start () 
    {
        m_ObjCube = GameObject.Find("ECube");
        m_ObjCube.AddComponent<movie>();
        //m_ObjCube.GetComponent<movie>().LoadRes();
    }
    
    // Update is called once per frame
    void Update () {
    
    }
}

 

相关文章:

  • HttpSession的关键属性和方法
  • GO語言基礎教程:數據類型,變量,常量
  • 写给ITpro同路人的十条建议
  • 在windows中安装Oracle 11g R2 数据库
  • Batch containing 11 record(s) expired due to timeout while requesting metadata
  • Drawable与Bitmap(转)
  • 依旧
  • SpringBoot Druid整合,SpringBoot 集成Druid
  • Exchange 2013 DAG报错“The fully qualified domain name for node “DAG” could notbefound”解决方法...
  • 20165211 2017-2018-2 《Java程序设计》第6周学习总结
  • Cocos2d-JS: 2.编译到安卓和iOS
  • CentOS程序包管理、下
  • Linux-RedHat 9.0 安装-总结
  • 用户登陆
  • 【OCM】Exam Souvenir 20140825
  • 【剑指offer】让抽象问题具体化
  • 2017年终总结、随想
  • ES10 特性的完整指南
  • ES6之路之模块详解
  • JAVA并发编程--1.基础概念
  • macOS 中 shell 创建文件夹及文件并 VS Code 打开
  • Meteor的表单提交:Form
  • OpenStack安装流程(juno版)- 添加网络服务(neutron)- controller节点
  • Python学习之路13-记分
  • Sass 快速入门教程
  • tab.js分享及浏览器兼容性问题汇总
  • Vue2 SSR 的优化之旅
  • yii2中session跨域名的问题
  • 个人博客开发系列:评论功能之GitHub账号OAuth授权
  • 世界编程语言排行榜2008年06月(ActionScript 挺进20强)
  • 推荐一个React的管理后台框架
  • 赢得Docker挑战最佳实践
  • elasticsearch-head插件安装
  • 阿里云ACE认证学习知识点梳理
  • #基础#使用Jupyter进行Notebook的转换 .ipynb文件导出为.md文件
  • (4)事件处理——(2)在页面加载的时候执行任务(Performing tasks on page load)...
  • (LeetCode) T14. Longest Common Prefix
  • (六)Hibernate的二级缓存
  • (论文阅读26/100)Weakly-supervised learning with convolutional neural networks
  • (三)终结任务
  • (四)图像的%2线性拉伸
  • (五)网络优化与超参数选择--九五小庞
  • (转)EOS中账户、钱包和密钥的关系
  • (转)ORM
  • (转)shell中括号的特殊用法 linux if多条件判断
  • (转载)Google Chrome调试JS
  • (最优化理论与方法)第二章最优化所需基础知识-第三节:重要凸集举例
  • ./indexer: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object fil
  • .NET 反射 Reflect
  • .NET/C# 使用反射调用含 ref 或 out 参数的方法
  • .NET开发不可不知、不可不用的辅助类(三)(报表导出---终结版)
  • .NET中两种OCR方式对比
  • /usr/bin/perl:bad interpreter:No such file or directory 的解决办法
  • @PreAuthorize注解
  • @Resource和@Autowired的区别