public override void OnFlowWindowLayoutGUI(Rect rect, FD.FlowWindow window) { if (window.isVisibleState == false) { return; } if (window.IsContainer() == true) { return; } if (window.IsSmall() == true && window.IsFunction() == true) { return; } if (window.IsShowDefault() == true) { return; } if (Heatmap.settings == null) { Heatmap.settings = Heatmap.GetSettingsFile(); } var settings = Heatmap.settings; if (settings != null) { var data = settings.data.Get(window); if (data == null) { return; } LayoutWindowType screen; var layout = HeatmapSystem.GetLayout(window.id, out screen); if (layout == null) { return; } var targetScreenSize = new Vector2(layout.root.editorRect.width, layout.root.editorRect.height); foreach (var item in settings.items) { if (item.show == true && item.enabled == true) { foreach (var serviceBase in this.editor.services) { var service = serviceBase as IAnalyticsService; if (service.GetServiceName() == item.serviceName) { var key = string.Format("{0}_{1}", item.serviceName, window.id); HeatmapResult result; if (this.heatmapResultsCache.TryGetValue(key, out result) == true) { if (result != null) { var texture = this.heatmapTexturesCache[key]; if (texture != null) { var scaleFactor = HeatmapSystem.GetFactor(targetScreenSize, rect.size); //var scaleFactorCanvas = layout.editorScale > 0f ? 1f / layout.editorScale : 1f; //scaleFactor *= scaleFactorCanvas; var r = layout.root.editorRect; r.x *= scaleFactor; r.y *= scaleFactor; r.x += rect.x + rect.width * 0.5f; r.y += rect.y + rect.height * 0.5f; r.width *= scaleFactor; r.height *= scaleFactor; var c = Color.white; GUI.color = c; GUI.DrawTexture(r, texture, ScaleMode.StretchToFill, alphaBlend: true); GUI.color = Color.white; } else { if (this.noDataTexture != null) { GUI.DrawTexture(rect, this.noDataTexture, ScaleMode.ScaleToFit, alphaBlend: true); } } } else { // still loading... } } else { if (Event.current.type == EventType.Repaint) { var rectSize = targetScreenSize; //rect.size; var rootRect = layout.root.editorRect; this.heatmapResultsCache.Add(key, null); this.heatmapTexturesCache.Add(key, null); service.GetHeatmapData(window.id, (int)targetScreenSize.x, (int)targetScreenSize.y, item.userFilter, (_result) => { var heatmapResult = _result as HeatmapResult; // Convert normalized points to real points for (int i = 0; i < heatmapResult.points.Length; ++i) { var root = layout.GetRootByTag((LayoutTag)heatmapResult.points[i].tag); if (root != null) { var xn = heatmapResult.points[i].x; var yn = heatmapResult.points[i].y; var sourceRect = root.editorRect; var radius = (float)HeatmapVisualizer.GetRadius(); sourceRect.x += radius; sourceRect.y += radius; sourceRect.width -= radius * 2f; sourceRect.height -= radius * 2f; var scaleFactor = HeatmapSystem.GetFactor(targetScreenSize, rectSize); var r = sourceRect; r.x *= scaleFactor; r.y *= scaleFactor; r.x += rootRect.width * 0.5f; r.y = rootRect.height * 0.5f - r.y; r.width *= scaleFactor; r.height *= scaleFactor; heatmapResult.points[i].realPoint = new Vector2(r.x + xn * r.width, r.y - yn * r.height); } } this.heatmapResultsCache[key] = heatmapResult; HeatmapSystem.GenerateTextureFromData((int)targetScreenSize.x, (int)targetScreenSize.y, this.heatmapResultsCache[key], (texture) => { this.heatmapTexturesCache[key] = texture; }); }); } } } } } } } }
public override void OnGUI() { if (Heatmap.styles == null) { Heatmap.styles = new Styles(); } if (this.openFullScreen == true) { var data = FlowSystem.GetData(); if (data == null) { return; } const float closeSize = 50f; LayoutWindowType screen; var layout = HeatmapSystem.GetLayout(this.fullScreenWindowId, out screen); if (layout == null) { return; } var window = FlowSystem.GetWindow(this.fullScreenWindowId); if (this.fullScreenEditor == null) { this.fullScreenEditor = Editor.CreateEditor(window.GetScreen().Load <WindowBase>()) as IPreviewEditor; } var rect = new Rect(0f, 0f, 780f, 580f); var scaleFactor = HeatmapSystem.GetFactor(new Vector2(layout.root.editorRectLocal.width, layout.root.editorRectLocal.height), rect.size); var r = layout.root.editorRectLocal; r.x *= scaleFactor; r.y *= scaleFactor; r.x += rect.x + rect.width * 0.5f; r.y += rect.y + rect.height * 0.5f; r.width *= scaleFactor; r.height *= scaleFactor; var screenRect = new Rect(0f, 0f, Screen.width, Screen.height); var settingsSize = rect.size; var settingsRect = new Rect(screenRect.width * 0.5f - settingsSize.x * 0.5f, screenRect.height * 0.5f - settingsSize.y * 0.5f, settingsSize.x, settingsSize.y).PixelPerfect(); var settingsBackRect = new Rect(settingsRect.x - MARGIN, settingsRect.y - MARGIN, settingsRect.width + MARGIN * 2f, settingsRect.height + MARGIN * 2f).PixelPerfect(); var rectCloseButton = new Rect(settingsRect.x + settingsRect.width, settingsRect.y - closeSize * 0.5f, closeSize, closeSize).PixelPerfect(); GUI.Box(screenRect, string.Empty, Heatmap.styles.backLock); GUI.Box(settingsBackRect, string.Empty, Heatmap.styles.dropShadow); GUI.Box(settingsBackRect, string.Empty, Heatmap.styles.contentScreen); var outRect = new Rect(r.x + settingsRect.x, r.y + settingsRect.y, r.width, r.height); GUI.Box(outRect, string.Empty, Heatmap.styles.layoutBack); this.fullScreenEditor.OnPreviewGUI(Color.white, new Rect(outRect.x, outRect.y, outRect.width, outRect.height), GUIStyle.none, selected: null, onSelection: null, highlighted: null); GUI.DrawTexture(outRect, this.fullScreenTexture, ScaleMode.StretchToFill, alphaBlend: true); if (GUI.Button(rectCloseButton, string.Empty, Heatmap.styles.closeButton) == true) { this.flowEditor.SetEnabled(); this.openFullScreen = false; } } }