示例#1
0
    void Awake()
    {
        videoPlayer = this.GetComponent <VideoPlayer>();
        audioSource = videoPlayer.GetComponentInChildren <AudioSource>();
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        videoPlayer.controlledAudioTrackCount = 1;
        audioSource.volume            = 1.0f;
        videoPlayer.loopPointReached += ReloadVideoAndPlay;

        videoTexture = videoPlayer.targetTexture;

        material       = this.GetComponent <MeshRenderer>().material;
        material.color = Color.gray;

        transform.position = (transform.position - center).normalized * radius + center;
        transform.LookAt(center, Vector3.up);

        originalPosition           = transform.position;
        originalDistanceFromCamera = radius;
        originalRotationSpeed      = rotationSpeed;

        allInteractables = this.GetComponentsInParent <XRBaseInteractable>();
    }
    void UpdateVideo(string localVideoPath)
    {
        if (localVideoPath == null)
        {
            videoPlayer.Stop();
            videoPlayer.source = VideoSource.VideoClip;
            videoPlayer.GetComponentInChildren <RawImage>().texture = null;
            return;
        }

        videoPlayer.source    = VideoSource.Url;
        videoPlayer.url       = localVideoPath;
        videoPlayer.isLooping = true;

        if (videoRenderTexture == null)
        {
            videoRenderTexture = new RenderTexture(1024, 728, 16, RenderTextureFormat.ARGB32);
            videoRenderTexture.Create();
        }

        videoPlayer.targetTexture = videoRenderTexture;
        videoPlayer.GetComponentInChildren <RawImage>().texture = videoRenderTexture;
        videoPlayer.Play();
    }
    // public Vector3 center = new Vector3(0,0,0);
    // public Vector3 axis = Vector3.up;
    // public float radius = 4.0f;
    // public float radiusSpeed = 0.05f;
    // public float rotationSpeed = 8.0f;

    void Awake()
    {
        videoPlayer                 = this.GetComponent <VideoPlayer>();
        videoPlayer.clip            = videoClip;
        audioSource                 = videoPlayer.GetComponentInChildren <AudioSource>();
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        videoPlayer.controlledAudioTrackCount = 1;
        audioSource.volume = 1.0f;

        material       = this.GetComponent <MeshRenderer>().material;
        material.color = Color.gray;

        originalPosition = this.gameObject.transform.position;

        // transform.position = (transform.position - center).normalized * radius + center;
    }