zoukankan      html  css  js  c++  java
  • Unity3D调用摄像头,画面为翻转的问题

    http://blog.csdn.net/a117653909/article/details/16119907

    Unity3D中新建一个工程,加一个Plane,新建一个C# 脚本,调用摄像头,不过显示的图片居然是翻转的,也就是头朝地下。调了半天,原来是Plane反掉了,Plane的Rotation X值改为90,Y改为180就可以了。


    晒下代码:

    [html] view plain copy
    1. using UnityEngine;  
    2. using System.Collections;  
    3.   
    4. public class C : MonoBehaviour   
    5. {  
    6.     WebCamTexture webcamTexture;  
    7.     // Use this for initialization  
    8.     void Start ()   
    9.     {  
    10.         WebCamDevice[] devices = WebCamTexture.devices;  
    11.         if (devices.Length > 0)  
    12.         {  
    13.             webcamTexture = new WebCamTexture(devices[0].name, 320, 240, 25);  
    14.             renderer.material.mainTexture = webcamTexture;  
    15.             webcamTexture.Play();  
    16.         }  
    17.     }  
    18.       
    19.     // Update is called once per frame  
    20.     void Update ()   
    21.     {  
    22.       
    23.     }  
    24. }  

    或者:

    [csharp] view plain copy
    1. using UnityEngine;  
    2. using System.Collections;  
    3.   
    4. public class B : MonoBehaviour   
    5. {  
    6.     public string deviceName;    
    7.     WebCamTexture tex;  
    8.       
    9.     IEnumerator Start()  
    10.     {  
    11.         //获取授权    
    12.         yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);    
    13.         if (Application.HasUserAuthorization(UserAuthorization.WebCam))    
    14.         {    
    15.             WebCamDevice[] devices = WebCamTexture.devices;    
    16.             deviceName = devices[0].name;    
    17.             tex = new WebCamTexture(deviceName, 480, 320, 25);    
    18.             renderer.material.mainTexture = tex;    
    19.             tex.Play();    
    20.         }  
    21.     }  
    22. }  

  • 相关阅读:
    c#redis使用
    不安全的HTTP方法(渗透实验)
    arguments.callee弃用与webuploader
    多线程系列1:经典卖票
    终于确定了系统lsass.exe占用cpu的根本原因了,速度来看一看!![转载]
    edit响应键盘的“咚咚”声音去掉
    delphi资源文件制作及使用详解
    MySQL server has gone away错误的解决办法
    MySQL server has gone away的解决方法
    MySQL
  • 原文地址:https://www.cnblogs.com/nafio/p/9137284.html
Copyright © 2011-2022 走看看