コード例 #1
0
 void Restart()
 {
     HeatmapViewModel.UpdateHeatpointShowTimes(GetNormalizedTime(1), GetNormalizedTime(2));
 }
コード例 #2
0
        public void OnGUI()
        {
            if (m_MaxTime == -1)
            {
                m_MaxTime = HeatmapViewModel.endFrame;
            }

            using (new GUILayout.VerticalScope())
            {
                videoRenderer.videoMaterial = EditorGUILayout.ObjectField("Video Material", videoRenderer.videoMaterial, typeof(Material), true) as Material;

                var separators = HeatmapViewModel.GetSeparators();

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField(m_ClipDropdown, GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                    m_ClipDropdownRect = EditorGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("", EditorStyles.boldLabel);
                    EditorGUILayout.EndVertical();
                    var clipNameSep = separators["clipName"];
                    EditorGUI.BeginChangeCheck();
                    m_ClipNameIndex = EditorGUI.Popup(m_ClipDropdownRect, m_ClipNameIndex, clipNameSep.separatorValues.ToArray());

                    if (EditorGUI.EndChangeCheck())
                    {
                        clipNameSep.selectedValue = clipNameSep.separatorValues[m_ClipNameIndex];
                        HeatmapViewModel.UpdateSeparator("clipName", clipNameSep);
                    }
                }

                EditorGUILayout.LabelField("Render Options", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
                var _player = HeatmapViewModel.videoPlayer;
                //Disable render options if the videoplayer hasn't been assigned
                EditorGUI.BeginDisabledGroup(_player == null);
                using (new EditorGUILayout.VerticalScope())
                {
                    if (videoRenderer != null)
                    {
                        videoRenderer.minRadius = EditorGUILayout.Slider(m_MinRadiusContent, videoRenderer.minRadius, m_minRadius, m_maxRaidus);
                        videoRenderer.maxRadius = videoRenderer.minRadius;
                        videoRenderer.decay     = EditorGUILayout.Slider(m_DecayRateContent, videoRenderer.decay, m_minDecay, m_maxDecay);

                        m_QualityIndex = EditorGUILayout.Popup("   Quality", m_QualityIndex, new string[] { "1X", "2X", "5X" });

                        if (_player != null)
                        {
                            int m_HeatMapWidthBase  = (int)_player.clip.width / 5;
                            int m_HeatMapHeightBase = (int)_player.clip.height / 5;

                            switch (m_QualityIndex)
                            {
                            case 0:
                                videoRenderer.heatMapWidth  = m_HeatMapWidthBase;
                                videoRenderer.heatMapHeight = m_HeatMapHeightBase;
                                break;;

                            case 1:
                                videoRenderer.heatMapWidth  = m_HeatMapWidthBase * 2;
                                videoRenderer.heatMapHeight = m_HeatMapHeightBase * 2;
                                break;

                            case 2:
                                videoRenderer.heatMapWidth  = m_HeatMapWidthBase * 5;
                                videoRenderer.heatMapHeight = m_HeatMapHeightBase * 5;
                                break;
                            }
                        }

                        videoRenderer.numPoints    = EditorGUILayout.IntSlider("   Points", videoRenderer.numPoints, 1, 2000);
                        videoRenderer.gradientSize = EditorGUILayout.IntSlider("   Gradient Fidelity", videoRenderer.gradientSize, 1, 256);


                        EditorGUI.BeginDisabledGroup(_player != null && _player.isPrepared == false);
                        if (_player != null)
                        {
                            var oldStartTime = ConvertNormalizedTimeToFrame(HeatmapViewModel.heatpointShowStartTime);
                            var temp         = ConvertNormalizedTimeToFrame(HeatmapViewModel.heatpointShowStartTime);

                            if (_player.isPlaying)
                            {
                                EditorGUI.BeginDisabledGroup(true);
                                temp = EditorGUILayout.IntSlider(m_FrameContent, Convert.ToInt32(_player.frame), 1, m_MaxTime);
                                EditorGUI.EndDisabledGroup();
                            }
                            else
                            {
                                temp = EditorGUILayout.IntSlider(m_FrameContent, (int)temp, 1, m_MaxTime);
                                if (temp != oldStartTime)
                                {
                                    _player.frame = temp;
                                }
                            }
                            if (temp != oldStartTime)
                            {
                                HeatmapViewModel.UpdateHeatpointShowTimes(GetNormalizedTime(temp), GetNormalizedTime(temp + 1));
                                m_Heatmapper.Repaint();
                            }
                        }

                        EditorGUILayout.Space();
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField("", GUILayout.Width(EditorGUIUtility.labelWidth - 4));

                            using (new EditorGUILayout.HorizontalScope())
                            {
                                if (GUILayout.Button(m_RestartContent))
                                {
                                    _player.Pause();
                                    _player.frame = 1;
                                    Restart();
                                }
                                GUIContent playButtonContent = _player != null && _player.isPlaying ? m_PauseContent : m_PlayContent;
                                if (GUILayout.Button(playButtonContent))
                                {
                                    if (_player.isPlaying)
                                    {
                                        _player.Pause();
                                    }
                                    else
                                    {
                                        _player.Play();
                                    }
                                }
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.Space();
                    }
                }
                EditorGUI.EndDisabledGroup();
                DisplayFunnelGui();
            }
        }