zoukankan      html  css  js  c++  java
  • (转)Unity3d游戏开场CG动画播放方式

    1.在一个plane上播放

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    using UnityEngine;
    using System.Collections;
    public class MobileMovieTexture : MonoBehaviour
    {
        public MovieTexture movTexture;
     
        void Start()
        {
            GetComponent<Renderer>().material.mainTexture = movTexture;
            movTexture.Play();
        }
    }

    Unity3d游戏开场CG动画播放方式 - 第1张  | 是幻觉

    2.GUI.DrawTexture

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    using UnityEngine;
    using System.Collections;
    public class moiveTextureGUi : MonoBehaviour
    {
        public MovieTexture mt;
     
        void Start()
        {
            mt.loop = true;
        }
        void OnGUI()
        {
            GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),mt,ScaleMode.StretchToFill);
     
            if (GUILayout.Button("play"))
            {
                if (!mt.isPlaying)
                {
                    mt.Play();
                }
            }
        }
    }

    Unity3d游戏开场CG动画播放方式 - 第2张  | 是幻觉

    3. Handheld.PlayFullScreenMovie

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    
    using UnityEngine;
    using System.Collections;
     
    /// <summary>
    /// 事先装个QuickTime
    /// 一般在游戏开始前,会播放一个CG动画,点击屏幕救你可以关闭了
    /// 视频文件放在StreamingAssets文件夹下
    /// </summary>
    public class TestHeadMoiveOnMobile : MonoBehaviour
    {
        void Start()
        {
            Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
        }
        void OnGUI()
        {
            //视频播放时触摸屏幕视频关闭
            if (GUI.Button(new Rect(20, 10, 300, 50), "PLAY ContronlMode.CancleOnTouch"))
            {
                Handheld.PlayFullScreenMovie("test.mp4",Color.black,FullScreenMovieControlMode.CancelOnInput);
            }
     
            //视频播放时弹出控件,控制视频暂停,播放,全屏等
            if (GUI.Button(new Rect(20, 90, 200, 50), "PLAY ControlMode.Full"))
            {
                Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Full);
            }
     
            //视频播放时无法停止,当其播放完一次 后自动关闭
            if (GUI.Button(new Rect(20, 170, 200, 50), "PLAY ControlMode.Hidden"))
            {
                Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Hidden);
            }
     
            //视频播放时弹出控件,可控制播放进度
            if (GUI.Button(new Rect(20, 250, 200, 50), "PLAY ControlMode.Minimal"))
            {
                Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Minimal);
            }
        }
    }

    Unity3d游戏开场CG动画播放方式 - 第3张  | 是幻觉

    第三种方式,只能在真机上测试,才有效果哦。
    一般选用:视频播放时触摸屏幕视频关闭
    Handheld.PlayFullScreenMovie(“test.mp4″,Color.black,FullScreenMovieControlMode.CancelOnInput);

  • 相关阅读:
    🔺 Garbage Remembering Exam UVA
    Cows and Cars UVA
    Probability|Given UVA
    Crossing Rivers HDU
    均匀分布和高斯分布
    Race to 1 UVA
    XMPPElementReceipt wait return,
    someone like you,
    第三方统计,
    截获的感觉,
  • 原文地址:https://www.cnblogs.com/backlighting/p/5061535.html
Copyright © 2011-2022 走看看