WebCamTexture.Play

Unity · Версия 2020.3 LTS · Scripting · WebCamTexture

WebCamTexture.Play

Объявление

public void Play();

Описание

Запускает камеру.

Вызовите Application.RequestUserAuthorization перед созданием Текстура веб-камеры.

// Запускает камеру по умолчанию и назначает текстуру текущему рендереру
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        WebCamTexture webcamTexture = new WebCamTexture();
        Renderer renderer = GetComponent<Renderer>();
        renderer.material.mainTexture = webcamTexture;
        webcamTexture.Play();
    }
}

Обновлено 17 ноября 2026 г.