AnimationCurve CreateFunnel() { AnimationCurve curve = new AnimationCurve(); Dictionary <float, int> _CountTable = new Dictionary <float, int>(); foreach (KeyValuePair <string, HeatPoint[]> kv in HeatmapViewModel.GetHeatpointToSessionMapping()) { for (int i = 0; i < kv.Value.Length; i++) { if (_CountTable.ContainsKey(kv.Value[i].time)) { _CountTable[kv.Value[i].time] = _CountTable[kv.Value[i].time] + 1; } else { _CountTable.Add(kv.Value[i].time, 1); } } } foreach (float m_time in _CountTable.Keys) { curve.AddKey(m_time, _CountTable[m_time]); } return(curve); }
void DisplayFunnelGui() { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(m_FunnelContent, EditorStyles.boldLabel, GUILayout.Width(EditorGUIUtility.labelWidth - 4)); using (new EditorGUILayout.VerticalScope()) { AnimationCurve m_Curve = CreateFunnel(); EditorGUI.CurveField(EditorGUILayout.GetControlRect(), m_Curve); var _player = HeatmapViewModel.videoPlayer; if (_player != null && _player.isPrepared) { EditorGUI.BeginDisabledGroup(true); float _StandardTime = _player.frame / (float)_player.frameCount; EditorGUILayout.LabelField(string.Format("Total number of players present: {0}", GetPresentPlayer(m_Curve, _StandardTime)), EditorStyles.label); EditorGUI.EndDisabledGroup(); } } } if (HeatmapViewModel.GetHeatpointToSessionMapping() == null || HeatmapViewModel.GetHeatpointToSessionMapping().Count() == 0) { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("There is no data currently to display.", MessageType.Warning); } }
void OnEnable() { EnsureHeatmapInstance(); viewModel = HeatmapViewModel.instance; m_Processor = new HeatmapDataProcessor(); m_Processor.RestoreSettings(); m_RenderView = HeatmapRendererInspector.Init(this, m_Processor); m_AggregationView = AggregationInspector.Init(m_Processor); m_AggregationView.OnEnable(); m_HeatmapperIconTexture = Resources.Load("unity_analytics_heatmaps_heatmapper") as Texture; viewModel.ManualOverride(); }
void Restart() { HeatmapViewModel.UpdateHeatpointShowTimes(GetNormalizedTime(1), GetNormalizedTime(2)); }
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(); } }