Ejemplo n.º 1
0
    protected override int GetNativeMovieTexutreID()
    {
#if (!UNITY_ANDROID && !UNITY_IPHONE) || UNITY_EDITOR
        UnityEngine.MovieTexture movieTexture = movieTextureObject as UnityEngine.MovieTexture;
        if (null != movieTexture)
        {
            return(movieTexture.GetNativeTextureID());
        }
#endif
        return(-1);
    }
Ejemplo n.º 2
0
        public void SetTexture2D(MovieTexture tex)
        {
            this.oggTexture = tex;

            renderer.material.SetTexture("_MainTex", tex);

            // In order to get texture size, we have to play the texture for one frame.
            // this is a known bug in unity.
            // http://forum.unity3d.com/threads/71220-get-MovieTexture-resolution
            tex.Play();
            tex.Pause();
            tex.loop = this.isLooping;
            this.textureAspectRatio = (float)tex.width / tex.height;
        }
Ejemplo n.º 3
0
Archivo: Video.cs Proyecto: leon196/WJ
        void Start()
        {
            materialEffect = GetComponent<Renderer>().material;

            var url = "file://" + Application.dataPath + "/StreamingAssets/Back To The Futur.ogg";

            var www = new WWW(url);

            movieTexture = (MovieTexture)www.movie;
            movieTexture.loop = true;
            movieTexture.Play();

            UnityEngine.Shader.SetGlobalTexture("_SamplerVideo", movieTexture);
        }
Ejemplo n.º 4
0
 static int GetMovieTexture(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.WWW          obj = (UnityEngine.WWW)ToLua.CheckObject(L, 1, typeof(UnityEngine.WWW));
         UnityEngine.MovieTexture o   = obj.GetMovieTexture();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    public void BindRenderTarget(int nativeTextureID_, AbstractMovieTextureComponent ownedMovieTextureComponent_, Material targetMaterial_)
    {
        if (null == targetMaterial_)
        {
            return;
        }

        if (true == this._editorMovieTextureDic.ContainsKey(nativeTextureID_))
        {
            this._editorMovieTextureDic.Remove(nativeTextureID_);
        }

        SPluginsMovieTexture spluginsMovieTexture = ownedMovieTextureComponent_ as SPluginsMovieTexture;

        if (null == spluginsMovieTexture)
        {
            return;
        }

        UnityEngine.MovieTexture movieTexture = spluginsMovieTexture.movieTextureObject as UnityEngine.MovieTexture;
        if (null == movieTexture)
        {
            return;
        }

        targetMaterial_.mainTexture = movieTexture;

        SEditorMovieTexture editorMovieTexture = new SEditorMovieTexture();

        editorMovieTexture.nativeTextureID            = nativeTextureID_;
        editorMovieTexture.movieTexture               = movieTexture;
        editorMovieTexture.ownedMovieTextureComponent = ownedMovieTextureComponent_;
        editorMovieTexture.mediaState = MediaState.IDLE;
        if (null != editorMovieTexture.ownedMovieTextureComponent)
        {
            editorMovieTexture.audioSource = editorMovieTexture.ownedMovieTextureComponent.GetComponent <AudioSource>();
            if (null == editorMovieTexture.audioSource)
            {
                editorMovieTexture.audioSource = editorMovieTexture.ownedMovieTextureComponent.gameObject.AddComponent <AudioSource>();
            }
        }
        this._editorMovieTextureDic.Add(nativeTextureID_, editorMovieTexture);
    }
Ejemplo n.º 6
0
        protected override void Awake()
        {
            Renderer VideoIntro = GetComponent<Renderer>();
            movie = (MovieTexture)VideoIntro.material.mainTexture;
            audioIntro = GetComponent<AudioSource>();
            audioIntro.clip = movie.audioClip;

            if (OnTransitionStarted == null)
                OnTransitionStarted = new TransitionEvent();

            OnTransitionStarted.AddListener(t => StartCoroutine(_PlayVideo()));
            OnTransitionEnded.AddListener(t =>
            {
                if (movie.isPlaying)
                {
                    StopAllCoroutines();
                    movie.Stop();
                    audioIntro.Stop();
                }
            });
            base.Awake();
        }
		// this gets overridden by AudioPlay...
		//public FsmFloat volume;

		public override void Reset()
		{
			movieTexture = null;
			gameObject = null;
			//volume = 1;
		}
Ejemplo n.º 8
0
 private static extern void INTERNAL_CALL_Pause(MovieTexture self);
Ejemplo n.º 9
0
 /// <summary>
 ///   <para>Pauses playing the movie.</para>
 /// </summary>
 public void Pause()
 {
     MovieTexture.INTERNAL_CALL_Pause(this);
 }
Ejemplo n.º 10
0
 private static extern void INTERNAL_CALL_Stop(MovieTexture self);
Ejemplo n.º 11
0
 /// <summary>
 ///   <para>Stops playing the movie, and rewinds it to the beginning.</para>
 /// </summary>
 public void Stop()
 {
     MovieTexture.INTERNAL_CALL_Stop(this);
 }
 private extern static void INTERNAL_CALL_Play(MovieTexture self);
Ejemplo n.º 13
0
        public override void ShowGUI()
        {
            #if UNITY_WEBGL

            EditorGUILayout.HelpBox ("This Action is not available on the WebGL platform.", MessageType.Info);

            #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8

            filePath = EditorGUILayout.TextField ("Path to clip file:", filePath);
            canSkip = EditorGUILayout.Toggle ("Player can skip?", canSkip);

            #elif UNITY_5 || UNITY_PRO_LICENSE

            movieClip = (MovieTexture) EditorGUILayout.ObjectField ("Movie clip:", movieClip, typeof (MovieTexture), false);
            if (movieClip)
            {
                EditorGUILayout.HelpBox ("The clip must be placed in a folder named 'StreamingAssets'.", MessageType.Info);
            }

            movieClipType = (MovieClipType) EditorGUILayout.EnumPopup ("Play clip:", movieClipType);
            if (movieClipType == MovieClipType.OnMaterial)
            {
                material = (Material) EditorGUILayout.ObjectField ("Material to play on:", material, typeof (Material), true);
            }

            includeAudio = EditorGUILayout.Toggle ("Include audio?", includeAudio);
            if (includeAudio)
            {
                sound = (Sound) EditorGUILayout.ObjectField ("Audio source:", sound, typeof (Sound), true);
            }

            if (movieClipType == MovieClipType.OnMaterial)
            {
                willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);
            }
            if (movieClipType == MovieClipType.FullScreen || willWait)
            {
                canSkip = EditorGUILayout.Toggle ("Player can skip?", canSkip);
                if (canSkip)
                {
                    skipKey = EditorGUILayout.TextField ("Skip with Input Button:", skipKey);
                }
            }

            #else
            EditorGUILayout.HelpBox ("On non-mobile platforms, this Action is only available in Unity 5 or Unity Pro.", MessageType.Warning);
            #endif

            AfterRunningOption ();
        }
		IEnumerator CoPlayMovieOGV(string path)
		{
			//WWWでロード
			using (WWW www = new WWW(ToStreamingPath(path)))
			{
				movieTexture = www.movie;
				if (movieTexture == null )
				{
					Debug.LogError("Movie Load Error:" + path);
				}
				else
				{
					while (!movieTexture.isReadyToPlay)
					{
						if(!string.IsNullOrEmpty(www.error))
						{
							Debug.LogError("Movie Load Error : " + www.error);
							break;
						}
						yield return 0;
					}
					if (string.IsNullOrEmpty(www.error))
					{
						yield return StartCoroutine(CoPlayMovieTexture(movieTexture));
					}
				}
			}
		}
		void PlayMovieTextue(string path)
		{
			isPlaying = true;
			string name = System.IO.Path.GetFileNameWithoutExtension(path);
			movieTexture = movieList.Find(item => (item.name == name));
			if (movieTexture)
			{
				StartCoroutine(CoPlayMovieTexture(movieTexture));
			}
			else
			{
				StartCoroutine(CoPlayMovieOGV(name));
			}
		}
Ejemplo n.º 16
0
 private static extern void INTERNAL_CALL_Stop(MovieTexture self);
Ejemplo n.º 17
0
 /**
  * <summary>Unassigns the currently-set MovieTexture to pause when the game is paused.
  * This should be called once the movie has finished playing.</summary>
  */
 public void StopFullScreenMovie()
 {
     fullScreenMovie = null;
 }
Ejemplo n.º 18
0
 /**
  * <summary>Assigns a MovieTexture as the one to pause when the game is paused.</summary>
  * <param name = "movieTexture">The MovieTexture to pause when the game is paused.</summary>
  */
 public void SetFullScreenMovie(MovieTexture movieTexture)
 {
     fullScreenMovie = movieTexture;
 }
Ejemplo n.º 19
0
		/// <summary>Removes all content from this image package.</summary>
		private void Clear(){
			// Clear any animation:
			GoingOffDisplay();
			Error=null;
			#if !MOBILE
			Video=null;
			#endif
			Image=null;
			SPAFile=null;
			IsVideo=false;
			Animated=false;
			IsDynamic=false;
			DynamicImage=null;
		}
Ejemplo n.º 20
0
		/// <summary>Called by the file handler when a video was retrieved successfully.</summary>
		/// <param name="video">The video received.</param>
		public void GotGraphic(MovieTexture movie){
			Clear();
			Video=movie;
			IsVideo=true;
			ImageReady(this);
		}
Ejemplo n.º 21
0
 private static extern void INTERNAL_CALL_Pause(MovieTexture self);
Ejemplo n.º 22
0
		public override void Reset()
		{
			movieTexture = null;
		}
		IEnumerator CoPlayMovieTexture(MovieTexture movieTexture)
		{
			PlayMovie ();
			while (movieTexture.isPlaying)
			{
				yield return 0;
			}
			StopMovieTexture();
		}
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     movieTexture = mat.mainTexture as MovieTexture;
     movieTexture.loop = true;
     movieTexture.Play();
 }
		void StopMovieTexture()
		{
			if(movieTexture)
			{
				movieTexture.Stop ();
				if (movieTexture.audioClip)
				{
					SoundManager.GetInstance().StopBgm();
				}
			}
			ClearRenderTargetTexture ();
			movieTexture = null;
			isPlaying = false;
			StopAllCoroutines();
		}
Ejemplo n.º 26
0
 /// <summary>
 ///   <para>Starts playing the movie.</para>
 /// </summary>
 public void Play()
 {
     MovieTexture.INTERNAL_CALL_Play(this);
 }
		}//Parse()

		/// <summary>
		/// Load a video from streaming assets
		/// </summary>
		public void Load(string name)
		{
			filename = name;
#if UNITY_STANDALONE || UNITY_WEBPLAYER
			if (GameManager.Instance.mainGame.ExternalResourcePath.Length == 0
				|| !System.IO.File.Exists(GameManager.Instance.mainGame.ExternalResourcePath + "/" + name + ".ogv"))
			{
				MovieTexture t = Resources.Load<MovieTexture>(name);
				if (t != null)
				{
					movie = t;
					this.gameObject.GetComponent<Renderer>().material.mainTexture = movie;
	 			}
			}
 			else
 			{
				ExternalVideoLoader loader = this.gameObject.GetComponent<ExternalVideoLoader>();
				if (loader == null)
				{
					loader = this.gameObject.AddComponent<ExternalVideoLoader>();
				}
				loader.Load(name, this);
			}
			Log.GameTimes("_________________ video - load complete");
#else
			Log.Warning("MovieTexture is disabled");
#endif
		}//Load()
 public void Update()
 {
     var prevStatus = _status;
      switch (prevStatus)
      {
          case StreamingVideoStatus.Unknown:
          case StreamingVideoStatus.Loading:
              if (_www != null)
              {
                  if (_www.error != null)
                  {
                      DebugStatus = _www.error;
                      _status = StreamingVideoStatus.Error;
                  }
                  bool movieReady = false;
                  bool audioReady = true;
                  if (_www.movie != null && _www.movie.isReadyToPlay)
                  {
                      Debug.Log("Movie ready");
                      movieReady = true;
                  }
                  //if (_www.movie.audioClip != null)
                  //{
                  //    Debug.Log("Audio Clip not null");
                  //    audioReady = false;
                  //    if (_www.movie.audioClip.loadState == AudioDataLoadState.Loaded)
                  //    {
                  //        Debug.Log("Audio Clip Ready");
                  //        audioReady = true;
                  //    }
                  //}
                  if (movieReady && audioReady)
                  {
                      Debug.Log("Ready To Play");
                      _status = StreamingVideoStatus.ReadyToPlay;
                      _movieTexture = _www.movie;
                      _audioClip = _movieTexture.audioClip;
                  }
                  else
                  {
                      _status = StreamingVideoStatus.Loading;
                  }
              }
              break;
          case StreamingVideoStatus.ReadyToPlay:
              if (_movieTexture.isPlaying)
              {
                  _status = StreamingVideoStatus.Playing;
              }
              break;
          case StreamingVideoStatus.Playing:
              if (!_movieTexture.isPlaying)
              {
                  _status = StreamingVideoStatus.Done;
              }
              break;
      }
 }