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); } }