void Update()
    {
        if (_movie != null)
        {
            if (_movie.OutputTexture != null)
            {
                _currentMovie = _movie;

                if (_movie.MovieInstance.RequiresFlipY)
                    _uiTexture.flip = UITexture.Flip.Vertically;

                if (_makePixelPerfect)
                {
                    _currentMovie.OutputTexture.filterMode = FilterMode.Point;
                    _uiTexture.mainTexture = _currentMovie.OutputTexture;
                    _uiTexture.MakePixelPerfect();
                }
                else
                {
                    _uiTexture.mainTexture = _currentMovie.OutputTexture;
                }

            }
        }
        else
        {
            _currentMovie = null;
            _uiTexture.mainTexture = _defaultTexture;
        }
    }
예제 #2
0
    void Update()
    {
        if (_movie != null)
        {
            if (_movie.OutputTexture != null)
            {
                _currentMovie = _movie;

                if (_movie.MovieInstance.RequiresFlipY)
                {
                    _uiTexture.flip = UITexture.Flip.Vertically;
                }

                if (_makePixelPerfect)
                {
                    _currentMovie.OutputTexture.filterMode = FilterMode.Point;
                    _uiTexture.mainTexture = _currentMovie.OutputTexture;
                    _uiTexture.MakePixelPerfect();
                }
                else
                {
                    _uiTexture.mainTexture = _currentMovie.OutputTexture;
                }
            }
        }
        else
        {
            _currentMovie          = null;
            _uiTexture.mainTexture = _defaultTexture;
        }
    }
예제 #3
0
    private void Add(string folder, string filename)
    {
        GameObject go = new GameObject();

        go.transform.parent = _root.transform;

        AVProWindowsMediaMovie movie = go.AddComponent <AVProWindowsMediaMovie>();

        movie._folder      = folder;
        movie._filename    = filename;
        movie._loop        = true;
        movie._loadOnStart = false;
        movie._playOnStart = false;

        AVProWindowsMediaGUIDisplay gui = go.AddComponent <AVProWindowsMediaGUIDisplay>();

        gui._movie      = movie;
        gui._scaleMode  = ScaleMode.StretchToFill;
        gui._fullScreen = false;
        gui._alphaBlend = false;
        gui._depth      = 5;
        gui._color      = new Color(0.8f, 0.8f, 0.8f, 1.0f);

        _movies.Add(gui);

        if (!movie.LoadMovie(true))
        {
            Remove(gui);
            return;
        }

        UpdateLayout();
    }
예제 #4
0
        protected override void OnStart()
        {
            base.OnStart();

            if (Renderer != null)
            {
                Renderer.material.mainTexture = Movie.OutputTexture;
            }

            Movie          = GetComponent <AVProWindowsMediaMovie>();
            _image.texture = Movie.OutputTexture;


            _page = GetComponent <Page.Page>();

            _pagesController = _bootstrap.GetController(ControllerTypes.Page) as PagesController;

            _id   = _page.Id;
            _type = _page.Type;

            _pagesController.NextPage     += CheckPage;
            _pagesController.PreviousPage += CheckPage;
            _pagesController.OpenPage     += CheckPage;
            _pagesController.OpenPageType += CheckPage;
        }
 void Start()
 {
     _audioMatrixValues = new float[_parent.NumChannels];
     windowRect = new Rect(Screen.width / 2, Screen.height / 2, windowRect.width, windowRect.height);
     _movie = this.gameObject.AddComponent<AVProWindowsMediaMovie>();
     _movie._useAudioMixer = true;
     _movie._loadOnStart = false;
     _movie._playOnStart = false;
 }
예제 #6
0
 void Start()
 {
     _audioMatrixValues    = new float[_parent.NumChannels];
     windowRect            = new Rect(Screen.width / 2, Screen.height / 2, windowRect.width, windowRect.height);
     _movie                = this.gameObject.AddComponent <AVProWindowsMediaMovie>();
     _movie._useAudioMixer = true;
     _movie._loadOnStart   = false;
     _movie._playOnStart   = false;
 }
예제 #7
0
    private void DrawVideoControls(Rect area, AVProWindowsMediaGUIDisplay movieGUI)
    {
        AVProWindowsMediaMovie movie  = movieGUI._movie;
        AVProWindowsMedia      player = movie.MovieInstance;

        if (player == null)
        {
            return;
        }

        // Close button
        if (GUI.Button(new Rect(area.x + (area.width - 32), area.y, 32, 32), "X"))
        {
            _removeMovie = movieGUI;
        }

        // Duplicate button
        if (GUI.Button(new Rect(area.x + (area.width - 64), area.y, 32, 32), "+"))
        {
            Add(movie._folder, movie._filename);
        }

        // Video properties
        GUILayout.BeginArea(new Rect(area.x, area.y, area.width / 2, area.height / 2));
        GUILayout.Label(player.Width + "x" + player.Height + "/" + player.FrameRate.ToString("F2") + "hz");
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(area.x, area.y + (area.height - 32), area.width, 32));
        GUILayout.BeginHorizontal();
        float position    = player.PositionSeconds;
        float newPosition = GUILayout.HorizontalSlider(position, 0.0f, player.DurationSeconds, GUILayout.ExpandWidth(true));

        if (position != newPosition)
        {
            player.PositionSeconds = newPosition;
        }
        if (player.IsPlaying)
        {
            if (GUILayout.Button("Pause", GUILayout.ExpandWidth(false)))
            {
                player.Pause();
            }
        }
        else
        {
            if (GUILayout.Button("Play", GUILayout.ExpandWidth(false)))
            {
                player.Play();
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
        protected override void OnStart()
        {
            base.OnStart();

            _controller.CallGenericAction += CallAnimation;

            if (Renderer != null)
            {
                Renderer.material.mainTexture = Movie.OutputTexture;
            }

            Movie          = GetComponent <AVProWindowsMediaMovie>();
            _image.texture = Movie.OutputTexture;
        }
        protected override void OnStart()
        {
            base.OnStart();

            if (Renderer != null)
            {
                Renderer.material.mainTexture = Movie.OutputTexture;
            }

            Movie          = GetComponent <AVProWindowsMediaMovie>();
            _image.texture = Movie.OutputTexture;

            UnityEngine.Debug.Log("_image.texture : " + _image.texture);
            Movie.Play();
        }
예제 #10
0
    void OnGUI()
    {
        AVProWindowsMediaMovie activeMovie = PlayingMovie;

        if (activeMovie.OutputTexture == null)
        {
            activeMovie = LoadingMovie; // Display the previous video until the current one has loaded the first frame
        }
        Texture texture = activeMovie.OutputTexture;

        if (texture != null)
        {
            Rect rect = new Rect(0, 0, Screen.width, Screen.height);

            if (activeMovie.MovieInstance.RequiresFlipY)
            {
                GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, rect.y + (rect.height / 2)));
            }

            GUI.DrawTexture(rect, texture, ScaleMode.ScaleToFit, false);
        }
    }
	public override void OnInspectorGUI()
	{
		_movie = (this.target) as AVProWindowsMediaMovie;

		EditorGUILayout.Separator();
		GUILayout.Label("File Location", EditorStyles.boldLabel);
		//DrawDefaultInspector();

		_movie._useStreamingAssetsPath = EditorGUILayout.Toggle("Use StreamingAssets", _movie._useStreamingAssetsPath);
		_movie._folder = EditorGUILayout.TextField("Folder", _movie._folder);
		_movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);

		GUILayout.BeginHorizontal();
		GUI.enabled = System.IO.File.Exists(_movie.GetFilePath());
		
#if UNITY_EDITOR_WIN
		if (GUILayout.Button("Show"))
		{
			ShowInExplorer(_movie.GetFilePath());
		}
#endif
		GUI.enabled &= _movie._useStreamingAssetsPath;

		if (GUILayout.Button("Select"))
		{
			string projectRoot = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, ".."));
			projectRoot = projectRoot.Replace('\\', '/');

			string path = _movie.GetFilePath();
			path = path.Remove(0, projectRoot.Length + 1);
					
			Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(path);
		}
		GUILayout.EndHorizontal();
		GUI.enabled = true;

		GUI.color = Color.green;
		if (GUILayout.Button("BROWSE"))
		{
			Browse(Application.streamingAssetsPath, ref _movie._filename, ref _movie._folder, ref _movie._useStreamingAssetsPath);
		}
		GUI.color = Color.white;

		if (string.IsNullOrEmpty(_movie.GetFilePath()))
		{
			if (_movie._loadOnStart)
			{
				GUI.color = Color.red;
				GUILayout.TextArea("Error: No file specfied");
				GUI.color = Color.white;
			}
			else
			{
				GUI.color = Color.yellow;
				GUILayout.TextArea("Warning: No file specfied");
				GUI.color = Color.white;
			}
		}
		else if (!System.IO.File.Exists(_movie.GetFilePath()))
		{
			GUI.color = Color.red;
			GUILayout.TextArea("Error: File not found");
			GUI.color = Color.white;
		}
		else
		{
			if (!_movie._useStreamingAssetsPath)
			{
				GUI.color = Color.yellow;
				GUILayout.TextArea("Warning: Files not in StreamingAssets will require manual copying for builds");
				GUI.color = Color.white;
			}
		}
		if (System.IO.Path.IsPathRooted(_movie._folder))
		{
			GUI.color = Color.yellow;
			GUILayout.TextArea("Warning: Absolute path is not ideal.  Better to use files relative to the project root");
			GUI.color = Color.white;
		}

		GUILayout.Space(10f);

		EditorGUILayout.Separator();
		GUILayout.Label("Load Options", EditorStyles.boldLabel);
		
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Colour Format");
		_movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
		EditorGUILayout.EndHorizontal();
		_movie._useDisplaySync = EditorGUILayout.Toggle("Use Display Sync", _movie._useDisplaySync);

		if (_movie._useDisplaySync)
		{
			if (
#if UNITY_5
				PlayerSettings.d3d11FullscreenMode != D3D11FullscreenMode.ExclusiveMode || 
#endif
				PlayerSettings.d3d9FullscreenMode != D3D9FullscreenMode.ExclusiveMode)
			{
				GUI.color = Color.cyan;
				GUILayout.TextArea("Perf: For display sync fullscreen mode should be set to EXCLUSIVE in Player Settings");
				GUI.color = Color.white;
			}
			if (QualitySettings.vSyncCount != 1 && QualitySettings.vSyncCount != 2)
			{
				GUI.color = Color.cyan;
				GUILayout.TextArea("Perf: For display sync vsync must be set to 1 or 2 in Quality Settings");
				GUI.color = Color.white;
			}
		}

		_movie._allowAudio = EditorGUILayout.Toggle("Allow Audio", _movie._allowAudio);
		GUI.enabled = _movie._allowAudio;
		{
			_movie._useAudioDelay = EditorGUILayout.Toggle("Use Audio Delay", _movie._useAudioDelay);
			_movie._useAudioMixer = EditorGUILayout.Toggle("Use Audio Mixer", _movie._useAudioMixer);
		}
		GUI.enabled = true;

		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Filter");
		_movie._textureFilterMode = (FilterMode)EditorGUILayout.EnumPopup(_movie._textureFilterMode);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Wrap");
		_movie._textureWrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(_movie._textureWrapMode);
		EditorGUILayout.EndHorizontal();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Start Options", EditorStyles.boldLabel);
		_movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
		GUI.enabled = _movie._loadOnStart;
		if (!_movie._loadOnStart)
			_movie._playOnStart = false;
		_movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
		GUI.enabled = true;
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
		_movie._ignoreFlips = EditorGUILayout.Toggle("Ignore Flips", _movie._ignoreFlips);
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();

		EditorGUILayout.Separator();
		GUILayout.Label("Playback", EditorStyles.boldLabel);

		_movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
		//_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);		

		GUI.enabled = _movie._allowAudio;
		{
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Audio Volume");
			_movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
			EditorGUILayout.EndHorizontal();

			
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Audio Balance");
			_movie._audioBalance = EditorGUILayout.Slider(_movie._audioBalance, -1.0f, 1.0f);
			EditorGUILayout.EndHorizontal();
		}
		GUI.enabled = true;
		
		GUILayout.Space(8.0f);

        SerializedProperty tps = serializedObject.FindProperty("_clips");
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tps, new GUIContent("Clips"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(8.0f);

		if (!Application.isPlaying)
		{
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button("Load"))
			{
				if (AVProWindowsMediaManager.Instance != null)
				{
					_movie.LoadMovie(_movie._playOnStart);
				}
			}

#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
			using (var scope = new EditorGUI.DisabledScope(_movie.MovieInstance == null))
#else
			EditorGUI.BeginDisabledGroup(_movie.MovieInstance == null);
#endif
			{
				if (GUILayout.Button("Unload"))
				{
					_movie.UnloadMovie();
				}
			}
#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
#else
			EditorGUI.EndDisabledGroup();
#endif

			EditorGUILayout.EndHorizontal();
		}

		AVProWindowsMedia media = _movie.MovieInstance;
		if (media != null)
		{
			GUI.enabled = (_movie != null && _movie.MovieInstance != null);
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");
			GUI.enabled = true;

            if (_movie._editorPreview && _movie.MovieInstance != null)
			{
				{
					Texture texture = _movie.OutputTexture;
					if (texture == null)
						texture = EditorGUIUtility.whiteTexture;

					float ratio = (float)texture.width / (float)texture.height;


					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					Rect textureRect = GUILayoutUtility.GetRect(Screen.width/2, Screen.width/2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					_showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha Channel");
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
					 
					Matrix4x4 prevMatrix = GUI.matrix;
					if (_movie.MovieInstance.RequiresFlipY)
					{
						GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
					}

					if (!_showAlpha)
						GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);
					else
						EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);

					GUI.matrix = prevMatrix;
				
					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
					GUILayout.FlexibleSpace();
					if (GUILayout.Button("Select Texture", GUILayout.ExpandWidth(false)))
					{
						Selection.activeObject = texture;
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));		
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					if (media.FramesTotal > 30)
					{
						GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
					}
					else
					{
						GUILayout.Label("Displaying at ... fps");	
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}

				if (_movie.enabled)
				{
					GUILayout.Space(8.0f);

					EditorGUILayout.LabelField("Frame:");
					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("<", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames--;
					}
					uint currentFrame = media.PositionFrames;
					if (currentFrame != uint.MaxValue)
					{
						int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.LastFrame);
						if (newFrame != currentFrame)
						{
							media.PositionFrames = (uint)newFrame;
						}
					}
					if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames++;
					}
					EditorGUILayout.EndHorizontal();

                    if (_movie.NumClips > 0)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Clips", EditorStyles.boldLabel);
                        for (int i = 0; i < _movie.NumClips; i++)
                        {
                            GUILayout.BeginHorizontal();
                            string clipName = _movie.GetClipName(i);
                            GUILayout.Label(clipName);
                            if (GUILayout.Button("Loop"))
                            {
                                _movie.PlayClip(clipName, true, false);
                            }
                            GUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Reset Clip"))
                            _movie.ResetClip();
                        EditorGUILayout.Separator();
                    }

					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("Rewind"))
					{
						_movie.MovieInstance.Rewind();
					}

					if (!media.IsPlaying)
					{
						if (GUILayout.Button("Play"))
						{
							_movie.Play();
						}						
					}
					else
					{
						if (GUILayout.Button("Pause"))
						{
							_movie.Pause();
						}
					}
					EditorGUILayout.EndHorizontal();

#if !AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
					this.Repaint();
#endif
				}
			}
        }
		if (GUI.changed)
		{
			EditorUtility.SetDirty(_movie);
		}

        // If the app isn't running but the media is we may need to manually update it
        if (!Application.isPlaying && _movie.MovieInstance != null)
        {
            _movie.Update();
            AVProWindowsMediaManager.Instance.Update();
            EditorUtility.SetDirty(_movie);
        }
	}
	public override void OnInspectorGUI()
	{
		_movie = (this.target) as AVProWindowsMediaMovie;
		
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Load Options", EditorStyles.boldLabel);
		//DrawDefaultInspector();

		_movie._folder = EditorGUILayout.TextField("Folder", _movie._folder);
		_movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);
		_movie._useStreamingAssetsPath = EditorGUILayout.Toggle("Use StreamingAssets", _movie._useStreamingAssetsPath);

#if UNITY_EDITOR_WIN
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel(" ");
		if (GUILayout.Button ("Show File"))
		{
			ShowInExplorer(_movie.GetFilePath());
		}
		EditorGUILayout.EndHorizontal();
#endif
		
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Colour Format");
		_movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
		EditorGUILayout.EndHorizontal();
		_movie._useDisplaySync = EditorGUILayout.Toggle("Use Display Sync", _movie._useDisplaySync);
		_movie._allowAudio = EditorGUILayout.Toggle("Allow Audio", _movie._allowAudio);
		if (_movie._allowAudio)
		{
			_movie._useAudioDelay = EditorGUILayout.Toggle("Use Audio Delay", _movie._useAudioDelay);
			_movie._useAudioMixer = EditorGUILayout.Toggle("Use Audio Mixer", _movie._useAudioMixer);
		}
		EditorGUILayout.Separator();
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Filter");
		_movie._textureFilterMode = (FilterMode)EditorGUILayout.EnumPopup(_movie._textureFilterMode);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.PrefixLabel("Texture Wrap");
		_movie._textureWrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(_movie._textureWrapMode);
		EditorGUILayout.EndHorizontal();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Start Options", EditorStyles.boldLabel);
		_movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
		_movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
		_movie._ignoreFlips = EditorGUILayout.Toggle("Ignore Flips", _movie._ignoreFlips);
		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		
		_movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
		//_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);		

		if (_movie._allowAudio)
		{
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Audio Volume");
			_movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
			EditorGUILayout.EndHorizontal();
		}		
		
		GUILayout.Space(8.0f);

        SerializedProperty tps = serializedObject.FindProperty("_clips");
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tps, new GUIContent("Clips"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(8.0f);

		if (!Application.isPlaying)
		{
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button("Load"))
			{
				if (AVProWindowsMediaManager.Instance != null)
				{
					_movie.LoadMovie(_movie._playOnStart);
				}
			}

			EditorGUI.BeginDisabledGroup(_movie.MovieInstance == null);
			if (GUILayout.Button("Unload"))
			{
				_movie.UnloadMovie();
			}
			EditorGUI.EndDisabledGroup();
			EditorGUILayout.EndHorizontal();
		}

		AVProWindowsMedia media = _movie.MovieInstance;
		if (media != null)
		{
			GUI.enabled = (_movie != null && _movie.MovieInstance != null);
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");
			GUI.enabled = true;

            if (_movie._editorPreview && _movie.MovieInstance != null)
			{
				{
					Texture texture = _movie.OutputTexture;
					if (texture == null)
						texture = EditorGUIUtility.whiteTexture;

					float ratio = (float)texture.width / (float)texture.height;


					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					Rect textureRect = GUILayoutUtility.GetRect(Screen.width/2, Screen.width/2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					_showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha Channel");
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
					 
					Matrix4x4 prevMatrix = GUI.matrix;
					if (_movie.MovieInstance.RequiresFlipY)
					{
						GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
					}

					if (!_showAlpha)
						GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);
					else
						EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);

					GUI.matrix = prevMatrix;
				
					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
					GUILayout.FlexibleSpace();
					if (GUILayout.Button("Select Texture", GUILayout.ExpandWidth(false)))
					{
						Selection.activeObject = texture;
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));		
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					GUILayout.FlexibleSpace();
					if (media.FramesTotal > 30)
					{
						GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
					}
					else
					{
						GUILayout.Label("Displaying at ... fps");	
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}

				if (_movie.enabled)
				{
					GUILayout.Space(8.0f);

					if (_movie._allowAudio)
					{
						EditorGUILayout.BeginHorizontal();
						EditorGUILayout.PrefixLabel("Audio Balance");
						media.AudioBalance = EditorGUILayout.Slider(media.AudioBalance, -1.0f, 1.0f);
						EditorGUILayout.EndHorizontal();

						EditorGUILayout.Separator();
					}

					EditorGUILayout.LabelField("Frame:");
					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("<", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames--;
					}
					uint currentFrame = media.PositionFrames;
					if (currentFrame != uint.MaxValue)
					{
						int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.LastFrame);
						if (newFrame != currentFrame)
						{
							media.PositionFrames = (uint)newFrame;
						}
					}
					if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
					{
						media.PositionFrames++;
					}
					EditorGUILayout.EndHorizontal();

                    if (_movie.NumClips > 0)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Clips", EditorStyles.boldLabel);
                        for (int i = 0; i < _movie.NumClips; i++)
                        {
                            GUILayout.BeginHorizontal();
                            string clipName = _movie.GetClipName(i);
                            GUILayout.Label(clipName);
                            if (GUILayout.Button("Loop"))
                            {
                                _movie.PlayClip(clipName, true, false);
                            }
                            GUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Reset Clip"))
                            _movie.ResetClip();
                        EditorGUILayout.Separator();
                    }

					EditorGUILayout.BeginHorizontal();
					if (GUILayout.Button("Rewind"))
					{
						_movie.MovieInstance.Rewind();
					}

					if (!media.IsPlaying)
					{
						if (GUILayout.Button("Play"))
						{
							_movie.Play();
						}						
					}
					else
					{
						if (GUILayout.Button("Pause"))
						{
							_movie.Pause();
						}
					}
					EditorGUILayout.EndHorizontal();

#if !AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
					this.Repaint();
#endif
				}
			}
        }
		if (GUI.changed)
		{
			EditorUtility.SetDirty(_movie);
		}

        // If the app isn't running but the media is we may need to manually update it
        if (!Application.isPlaying && _movie.MovieInstance != null)
        {
            _movie.Update();
            AVProWindowsMediaManager.Instance.Update();
            EditorUtility.SetDirty(_movie);
        }
	}
    public override void OnInspectorGUI()
    {
        _movie = (this.target) as AVProWindowsMediaMovie;

        //DrawDefaultInspector();
        _movie._folder = EditorGUILayout.TextField("Folder", _movie._folder);
        _movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Colour Format");
        _movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
        EditorGUILayout.EndHorizontal();

        _movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
        _movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
        _movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
        //_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Audio Volume");
        _movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(8.0f);

        AVProWindowsMedia media = _movie.MovieInstance;
        if (media != null)
        {
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");

            if (_movie._editorPreview)
            {
                {
                    Rect textureRect = GUILayoutUtility.GetRect(64.0f, 64.0f, GUILayout.MinWidth(64.0f), GUILayout.MinHeight(64.0f));
                    Texture texture = _movie.OutputTexture;
                    if (texture == null)
                        texture = EditorGUIUtility.whiteTexture;
                    GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);

                    if (Application.isPlaying && media != null)
                    {
                        GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));
                    }

                    if (media.FramesTotal > 30)
                    {
                        GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
                    }
                    else
                    {
                        GUILayout.Label("Displaying at ... fps");
                    }
                }

                if (Application.isPlaying && _movie.enabled)
                {
                    if (media != null)
                    {
                        GUILayout.Space(8.0f);
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel("Audio Balance");
                        media.AudioBalance = EditorGUILayout.Slider(media.AudioBalance, -1.0f, 1.0f);
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.LabelField("Frame:");
                        uint currentFrame = media.PositionFrames;
                        int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.DurationFrames);
                        if (newFrame != currentFrame)
                        {
                            media.PositionFrames = (uint)newFrame;
                        }

                        if (!media.IsPlaying)
                        {
                            if (GUILayout.Button("Unpause Stream"))
                            {
                                _movie.Play();
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Pause Stream"))
                            {
                                _movie.Pause();
                            }
                        }
                        if (_movie._editorPreview && media.IsPlaying)
                        {
                            UnityEditor.HandleUtility.Repaint();
                        }
                    }
                }
            }
        }
    }
 public void SetNextMovie(AVProWindowsMediaMovie movie)
 {
     _movie = movie;
     Update();
 }
    public void ControlWindow(int id)
    {
        if (_demo == null)
        {
            return;
        }

        GUILayout.Space(16f);

        GUILayout.BeginVertical("box");


        AVProWindowsMediaMovie movie = _demo.PlayingMovie;

        if (movie != null)
        {
            AVProWindowsMedia moviePlayer = movie.MovieInstance;
            if (moviePlayer != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Playing", GUILayout.Width(80));
                GUILayout.Label(movie._filename + " (" + moviePlayer.Width + "x" + moviePlayer.Height + " @ " + moviePlayer.FrameRate.ToString("F2") + ")");
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Time ", GUILayout.Width(80));
                GUILayout.HorizontalSlider(moviePlayer.PositionSeconds, 0.0f, moviePlayer.DurationSeconds, GUILayout.ExpandWidth(true));
                GUILayout.Label(moviePlayer.PositionSeconds.ToString("F1") + "/" + moviePlayer.DurationSeconds.ToString("F1") + "s", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();
            }
        }

        GUILayout.BeginHorizontal();
        //GUILayout.Space(80);
        GUILayout.Label(string.Empty, GUILayout.Width(80));
        if (GUILayout.Button("Prev"))
        {
            _demo.Previous();
        }

        if (_demo.IsPaused)
        {
            if (GUILayout.Button("Play"))
            {
                _demo.Unpause();
            }
        }
        else
        {
            if (GUILayout.Button("Pause"))
            {
                _demo.Pause();
            }
        }

        if (GUILayout.Button("Next"))
        {
            _demo.Next();
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(32f);


        GUILayout.BeginHorizontal();
        GUILayout.Label("Folder: ", GUILayout.Width(80));
        _demo._folder = GUILayout.TextField(_demo._folder, 192);
        GUILayout.EndHorizontal();
        GUILayout.Space(32f);


        int removeIndex = -1;
        int cloneIndex  = -1;
        int upIndex     = -1;
        int downIndex   = -1;

        GUILayout.Label("Playlist");
        for (int movieIndex = 0; movieIndex < _demo._filenames.Count; movieIndex++)
        {
            Color prevBackCol = GUI.backgroundColor;
            if (movieIndex == _demo.PlayingItemIndex)
            {
                GUI.backgroundColor = Color.green;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label((movieIndex + 1).ToString(), GUILayout.Width(80));
            _demo._filenames[movieIndex] = GUILayout.TextField(_demo._filenames[movieIndex], 192, GUILayout.MinWidth(256f));
            if (GUILayout.Button("X", GUILayout.Width(24)))
            {
                removeIndex = movieIndex;
            }
            if (GUILayout.Button("Clone", GUILayout.Width(64)))
            {
                cloneIndex = movieIndex;
            }
            if (GUILayout.Button("Up", GUILayout.Width(32)))
            {
                upIndex = movieIndex;
            }
            if (GUILayout.Button("Down", GUILayout.Width(48)))
            {
                downIndex = movieIndex;
            }
            GUILayout.EndHorizontal();

            if (movieIndex == _demo.PlayingItemIndex)
            {
                GUI.backgroundColor = prevBackCol;
            }
        }

        if (removeIndex >= 0)
        {
            _demo._filenames.RemoveAt(removeIndex);
            removeIndex = -1;
        }
        if (cloneIndex >= 0)
        {
            _demo._filenames.Insert(cloneIndex + 1, _demo._filenames[cloneIndex]);
        }

        if (upIndex > 0)
        {
            int    indexA = upIndex - 1;
            int    indexB = upIndex;
            string old    = _demo._filenames[indexA];
            _demo._filenames[indexA] = _demo._filenames[indexB];
            _demo._filenames[indexB] = old;
        }
        if (downIndex > 0 && downIndex + 1 < _demo._filenames.Count)
        {
            int    indexA = downIndex + 1;
            int    indexB = downIndex;
            string old    = _demo._filenames[indexA];
            _demo._filenames[indexA] = _demo._filenames[indexB];
            _demo._filenames[indexB] = old;
        }

        if (GUILayout.Button("+"))
        {
            _demo._filenames.Add(string.Empty);
        }



        GUILayout.EndVertical();
    }
    public override void OnInspectorGUI()
    {
        _movie = (this.target) as AVProWindowsMediaMovie;

        EditorGUILayout.Separator();
        GUILayout.Label("File Location", EditorStyles.boldLabel);
        //DrawDefaultInspector();

        _movie._useStreamingAssetsPath = EditorGUILayout.Toggle("Use StreamingAssets", _movie._useStreamingAssetsPath);
        _movie._folder   = EditorGUILayout.TextField("Folder", _movie._folder);
        _movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);

        GUILayout.BeginHorizontal();
        GUI.enabled = System.IO.File.Exists(_movie.GetFilePath());

#if UNITY_EDITOR_WIN
        if (GUILayout.Button("Show"))
        {
            ShowInExplorer(_movie.GetFilePath());
        }
#endif
        GUI.enabled &= _movie._useStreamingAssetsPath;

        if (GUILayout.Button("Select"))
        {
            string projectRoot = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, ".."));
            projectRoot = projectRoot.Replace('\\', '/');

            string path = _movie.GetFilePath();
            path = path.Remove(0, projectRoot.Length + 1);

            Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(path);
        }
        GUILayout.EndHorizontal();
        GUI.enabled = true;

        GUI.color = Color.green;
        if (GUILayout.Button("BROWSE"))
        {
            Browse(Application.streamingAssetsPath, ref _movie._filename, ref _movie._folder, ref _movie._useStreamingAssetsPath);
        }
        GUI.color = Color.white;

        if (string.IsNullOrEmpty(_movie.GetFilePath()))
        {
            if (_movie._loadOnStart)
            {
                GUI.color = Color.red;
                GUILayout.TextArea("Error: No file specfied");
                GUI.color = Color.white;
            }
            else
            {
                GUI.color = Color.yellow;
                GUILayout.TextArea("Warning: No file specfied");
                GUI.color = Color.white;
            }
        }
        else if (!System.IO.File.Exists(_movie.GetFilePath()))
        {
            GUI.color = Color.red;
            GUILayout.TextArea("Error: File not found");
            GUI.color = Color.white;
        }
        else
        {
            if (!_movie._useStreamingAssetsPath)
            {
                GUI.color = Color.yellow;
                GUILayout.TextArea("Warning: Files not in StreamingAssets will require manual copying for builds");
                GUI.color = Color.white;
            }
        }
        if (System.IO.Path.IsPathRooted(_movie._folder))
        {
            GUI.color = Color.yellow;
            GUILayout.TextArea("Warning: Absolute path is not ideal.  Better to use files relative to the project root");
            GUI.color = Color.white;
        }

        GUILayout.Space(10f);

        EditorGUILayout.Separator();
        GUILayout.Label("Load Options", EditorStyles.boldLabel);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Colour Format");
        _movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
        EditorGUILayout.EndHorizontal();
        _movie._useDisplaySync = EditorGUILayout.Toggle("Use Display Sync", _movie._useDisplaySync);

        if (_movie._useDisplaySync)
        {
            if (
#if UNITY_5
                PlayerSettings.d3d11FullscreenMode != D3D11FullscreenMode.ExclusiveMode ||
#endif
                PlayerSettings.d3d9FullscreenMode != D3D9FullscreenMode.ExclusiveMode)
            {
                GUI.color = Color.cyan;
                GUILayout.TextArea("Perf: For display sync fullscreen mode should be set to EXCLUSIVE in Player Settings");
                GUI.color = Color.white;
            }
            if (QualitySettings.vSyncCount != 1 && QualitySettings.vSyncCount != 2)
            {
                GUI.color = Color.cyan;
                GUILayout.TextArea("Perf: For display sync vsync must be set to 1 or 2 in Quality Settings");
                GUI.color = Color.white;
            }
        }

        _movie._allowAudio = EditorGUILayout.Toggle("Allow Audio", _movie._allowAudio);
        GUI.enabled        = _movie._allowAudio;
        {
            _movie._useAudioDelay = EditorGUILayout.Toggle("Use Audio Delay", _movie._useAudioDelay);
            _movie._useAudioMixer = EditorGUILayout.Toggle("Use Audio Mixer", _movie._useAudioMixer);
        }
        GUI.enabled = true;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Filter");
        _movie._textureFilterMode = (FilterMode)EditorGUILayout.EnumPopup(_movie._textureFilterMode);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Wrap");
        _movie._textureWrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(_movie._textureWrapMode);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Start Options", EditorStyles.boldLabel);
        _movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
        GUI.enabled         = _movie._loadOnStart;
        if (!_movie._loadOnStart)
        {
            _movie._playOnStart = false;
        }
        _movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
        GUI.enabled         = true;
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Performance", EditorStyles.boldLabel);
        _movie._ignoreFlips = EditorGUILayout.Toggle("Ignore Flips", _movie._ignoreFlips);
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        EditorGUILayout.Separator();
        GUILayout.Label("Playback", EditorStyles.boldLabel);

        _movie._loop = EditorGUILayout.Toggle("Loop", _movie._loop);
        //_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);

        GUI.enabled = _movie._allowAudio;
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Audio Volume");
            _movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Audio Balance");
            _movie._audioBalance = EditorGUILayout.Slider(_movie._audioBalance, -1.0f, 1.0f);
            EditorGUILayout.EndHorizontal();
        }
        GUI.enabled = true;

        GUILayout.Space(8.0f);

        SerializedProperty tps = serializedObject.FindProperty("_clips");
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(tps, new GUIContent("Clips"), true);
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }

        GUILayout.Space(8.0f);

        if (!Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Load"))
            {
                if (AVProWindowsMediaManager.Instance != null)
                {
                    _movie.LoadMovie(_movie._playOnStart);
                }
            }

#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
            using (var scope = new EditorGUI.DisabledScope(_movie.MovieInstance == null))
#else
            EditorGUI.BeginDisabledGroup(_movie.MovieInstance == null);
#endif
            {
                if (GUILayout.Button("Unload"))
                {
                    _movie.UnloadMovie();
                }
            }
#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 && !UNITY_5_3
#else
            EditorGUI.EndDisabledGroup();
#endif

            EditorGUILayout.EndHorizontal();
        }

        AVProWindowsMedia media = _movie.MovieInstance;
        if (media != null)
        {
            GUI.enabled           = (_movie != null && _movie.MovieInstance != null);
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");
            GUI.enabled           = true;

            if (_movie._editorPreview && _movie.MovieInstance != null)
            {
                {
                    Texture texture = _movie.OutputTexture;
                    if (texture == null)
                    {
                        texture = EditorGUIUtility.whiteTexture;
                    }

                    float ratio = (float)texture.width / (float)texture.height;


                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    Rect textureRect = GUILayoutUtility.GetRect(Screen.width / 2, Screen.width / 2, (Screen.width / 2) / ratio, (Screen.width / 2) / ratio);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    _showAlpha = GUILayout.Toggle(_showAlpha, "Show Alpha Channel");
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    Matrix4x4 prevMatrix = GUI.matrix;
                    if (_movie.MovieInstance.RequiresFlipY)
                    {
                        GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, textureRect.y + (textureRect.height / 2)));
                    }

                    if (!_showAlpha)
                    {
                        GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);
                    }
                    else
                    {
                        EditorGUI.DrawTextureAlpha(textureRect, texture, ScaleMode.ScaleToFit);
                    }

                    GUI.matrix = prevMatrix;

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Select Texture", GUILayout.ExpandWidth(false)))
                    {
                        Selection.activeObject = texture;
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (media.FramesTotal > 30)
                    {
                        GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
                    }
                    else
                    {
                        GUILayout.Label("Displaying at ... fps");
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                if (_movie.enabled)
                {
                    GUILayout.Space(8.0f);

                    EditorGUILayout.LabelField("Frame:");
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("<", GUILayout.ExpandWidth(false)))
                    {
                        media.PositionFrames--;
                    }
                    uint currentFrame = media.PositionFrames;
                    if (currentFrame != uint.MaxValue)
                    {
                        int newFrame = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.LastFrame);
                        if (newFrame != currentFrame)
                        {
                            media.PositionFrames = (uint)newFrame;
                        }
                    }
                    if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
                    {
                        media.PositionFrames++;
                    }
                    EditorGUILayout.EndHorizontal();

                    if (_movie.NumClips > 0)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Clips", EditorStyles.boldLabel);
                        for (int i = 0; i < _movie.NumClips; i++)
                        {
                            GUILayout.BeginHorizontal();
                            string clipName = _movie.GetClipName(i);
                            GUILayout.Label(clipName);
                            if (GUILayout.Button("Loop"))
                            {
                                _movie.PlayClip(clipName, true, false);
                            }
                            GUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Reset Clip"))
                        {
                            _movie.ResetClip();
                        }
                        EditorGUILayout.Separator();
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Rewind"))
                    {
                        _movie.MovieInstance.Rewind();
                    }

                    if (!media.IsPlaying)
                    {
                        if (GUILayout.Button("Play"))
                        {
                            _movie.Play();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Pause"))
                        {
                            _movie.Pause();
                        }
                    }
                    EditorGUILayout.EndHorizontal();

#if !AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
                    this.Repaint();
#endif
                }
            }
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(_movie);
        }

        // If the app isn't running but the media is we may need to manually update it
        if (!Application.isPlaying && _movie.MovieInstance != null)
        {
            _movie.Update();
            AVProWindowsMediaManager.Instance.Update();
            EditorUtility.SetDirty(_movie);
        }
    }
예제 #17
0
 public void SetNextMovie(AVProWindowsMediaMovie movie)
 {
     _movie = movie;
     Update();
 }
예제 #18
0
    public override void OnInspectorGUI()
    {
        _movie = (this.target) as AVProWindowsMediaMovie;

        //DrawDefaultInspector();
        _movie._folder   = EditorGUILayout.TextField("Folder", _movie._folder);
        _movie._filename = EditorGUILayout.TextField("Filename", _movie._filename);



        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Colour Format");
        _movie._colourFormat = (AVProWindowsMediaMovie.ColourFormat)EditorGUILayout.EnumPopup(_movie._colourFormat);
        EditorGUILayout.EndHorizontal();

        _movie._loop        = EditorGUILayout.Toggle("Loop", _movie._loop);
        _movie._loadOnStart = EditorGUILayout.Toggle("Load On Start", _movie._loadOnStart);
        _movie._playOnStart = EditorGUILayout.Toggle("Play On Start", _movie._playOnStart);
        //_movie._editorPreview = EditorGUILayout.Toggle("Editor Preview", _movie._editorPreview);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Audio Volume");
        _movie._volume = EditorGUILayout.Slider(_movie._volume, 0.0f, 1.0f);
        EditorGUILayout.EndHorizontal();


        GUILayout.Space(8.0f);

        AVProWindowsMedia media = _movie.MovieInstance;

        if (media != null)
        {
            _movie._editorPreview = EditorGUILayout.Foldout(_movie._editorPreview, "Video Preview");

            if (_movie._editorPreview)
            {
                {
                    Rect    textureRect = GUILayoutUtility.GetRect(64.0f, 64.0f, GUILayout.MinWidth(64.0f), GUILayout.MinHeight(64.0f));
                    Texture texture     = _movie.OutputTexture;
                    if (texture == null)
                    {
                        texture = EditorGUIUtility.whiteTexture;
                    }
                    GUI.DrawTexture(textureRect, texture, ScaleMode.ScaleToFit);

                    if (Application.isPlaying && media != null)
                    {
                        GUILayout.Label(string.Format("{0}x{1} @ {2}fps {3} secs", media.Width, media.Height, media.FrameRate.ToString("F2"), media.DurationSeconds.ToString("F2")));
                    }

                    if (media.FramesTotal > 30)
                    {
                        GUILayout.Label("Displaying at " + media.DisplayFPS.ToString("F1") + " fps");
                    }
                    else
                    {
                        GUILayout.Label("Displaying at ... fps");
                    }
                }

                if (Application.isPlaying && _movie.enabled)
                {
                    if (media != null)
                    {
                        GUILayout.Space(8.0f);
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel("Audio Balance");
                        media.AudioBalance = EditorGUILayout.Slider(media.AudioBalance, -1.0f, 1.0f);
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.LabelField("Frame:");
                        uint currentFrame = media.PositionFrames;
                        int  newFrame     = EditorGUILayout.IntSlider((int)currentFrame, 0, (int)media.DurationFrames);
                        if (newFrame != currentFrame)
                        {
                            media.PositionFrames = (uint)newFrame;
                        }

                        if (!media.IsPlaying)
                        {
                            if (GUILayout.Button("Unpause Stream"))
                            {
                                _movie.Play();
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Pause Stream"))
                            {
                                _movie.Pause();
                            }
                        }
                        if (_movie._editorPreview && media.IsPlaying)
                        {
                            UnityEditor.HandleUtility.Repaint();
                        }
                    }
                }
            }
        }
    }