コード例 #1
0
    void LateUpdate()
    {
        // Only create movie once
        if (createMovie == false)
        {
            return;
        }
        createMovie = false;

        if (movieFile.Length == 0)
        {
            Debug.LogError("No movie texture file specified");
            return;
        }

        String fullPath = AssetsManager.getAssetPath(movieFile);

        if (fullPath == null)
        {
            Debug.Log("Movie texture file not found in streaming assets, using absolute path: " + movieFile);
            fullPath = movieFile;
        }

        movieGeometry = MetaioSDKUnity.createGeometryFromMovie(fullPath);

        if (movieGeometry == IntPtr.Zero)
        {
            throw new Exception(string.Format("Failed to load movie {0}", fullPath));
        }

        movieGeometryToGameObjectNameCache[movieGeometry] = this.name;

        createTexture();

        MetaioSDKUnity.setMovieTextureTargetTextureID(movieGeometry, textureID);

        Debug.Log("Loaded movie " + movieFile);

        if (autoResizeGameObjectToVideoDimensions)
        {
            autoResizeGameObject();
        }

        // If we know the video frame is rotated, we automatically rotate it to the correct orientation here
        if (isRotatedCCW)
        {
            // Y axis (green) faces up from the plane, so do left-handed 90° rotation (i.e. clockwise by 90°)
            gameObject.transform.Rotate(new Vector3(0, 90, 0));
        }

        // if the associated GameObject is visible, play movie if it should
        // be played
        if (gameObject.renderer.isVisible && isPlaying)
        {
            play(isLooping);
        }
    }