类型或命名空间名称'MovieTexture'找不到.您是否缺少using指令或程序集引用?

本文关键字:指令 using 程序集 引用 找不到 命名空间 MovieTexture 类型 是否 | 更新日期: 2023-09-27 18:13:22

在执行应用程序的过程中,我遇到了

错误(CS0246)误差

当我尝试使用WebGL在unity上构建游戏时。下面是代码:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

[RequireComponent (typeof(AudioSource))]
public class videoplayer : MonoBehaviour {
private MovieTexture movie;
private AudioSource audio;

    void Start () {
        GetComponent<RawImage>().texture = movie as MovieTexture;
        audio = GetComponent<AudioSource>();
        audio.clip = movie.audioClip;
        movie.Play ();
        audio.Play();

    }

    void Update () {
    }
}

类型或命名空间名称'MovieTexture'找不到.您是否缺少using指令或程序集引用?

好了,我明白了。基本上,只声明movie,不给它赋任何值。这就是为什么它是空的。
我想你已经错过了对象的名称,其纹理属性在这里使用

GetComponent<RawImage>().texture = movie as MovieTexture; .

应该是这样的:

GetComponent<RawImage>()."THE NAME".texture = movie as MovieTexture;