AVProWindowsMediaManagerEditor.cs
2.61 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Support for Editor.RequiresConstantRepaint()
#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_5
#define AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
#endif
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
//-----------------------------------------------------------------------------
// Copyright 2012-2016 RenderHeads Ltd. All rights reserved.
//-----------------------------------------------------------------------------
[CustomEditor(typeof(AVProWindowsMediaManager))]
public class AVProWindowsMediaManagerEditor : Editor
{
private AVProWindowsMediaManager _manager;
private AVProWindowsMediaMovie[] _movies;
private void UpdateMovies()
{
_movies = (AVProWindowsMediaMovie[])FindObjectsOfType(typeof(AVProWindowsMediaMovie));
}
#if AVPROWINDOWSMEDIA_UNITYFEATURE_EDITORAUTOREFRESH
public override bool RequiresConstantRepaint ()
{
return (_movies != null);
}
#endif
public override void OnInspectorGUI()
{
_manager = (this.target) as AVProWindowsMediaManager;
if (!Application.isPlaying)
{
this.DrawDefaultInspector();
}
/*if (!Application.isPlaying)
{
_manager._useExternalTextures = GUILayout.Toggle(_manager._useExternalTextures, "Use External Textures (beta)");
}*/
if (GUILayout.Button ("Update"))
{
UpdateMovies();
}
if (_movies != null && _movies.Length > 0)
{
for (int i = 0; i < _movies.Length; i++)
{
GUILayout.BeginHorizontal();
GUI.color = Color.white;
if (!_movies[i].enabled || !_movies[i].gameObject.activeInHierarchy)
GUI.color = Color.grey;
AVProWindowsMedia media = _movies[i].MovieInstance;
if (media != null)
{
GUI.color = Color.yellow;
if (media.IsPlaying)
GUI.color = Color.green;
}
if (GUILayout.Button("S"))
{
Selection.activeObject = _movies[i];
}
GUILayout.Label(i.ToString("D2") + " " + _movies[i].name, GUILayout.MinWidth(128f));
//GUILayout.FlexibleSpace();
if (media != null)
{
GUILayout.Label(media.Width + "x" + media.Height);
GUILayout.FlexibleSpace();
GUILayout.Label(string.Format("{0:00.0}", media.DisplayFPS) + " FPS");
//GUILayout.FlexibleSpace();
}
else
{
GUILayout.FlexibleSpace();
}
GUILayout.EndHorizontal();
if (media != null)
{
GUILayout.HorizontalSlider(media.PositionSeconds, 0f, media.DurationSeconds, GUILayout.MinWidth(128f), GUILayout.ExpandWidth(true));
}
}
}
else
{
if (Event.current.type.Equals(EventType.Repaint))
{
UpdateMovies();
}
}
if (GUI.changed)
{
EditorUtility.SetDirty(_manager);
}
}
}