public override void OnFlowWindowScreenMenuGUI(FD.FlowWindow window, GenericMenu menu)
        {
            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;
                }

                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);
                                var windowId = window.id;
                                menu.AddItem(new GUIContent("Open Heatmap..."), false, () => {
                                    //this.fullScreenData = this.heatmapResultsCache[key];
                                    this.fullScreenTexture  = this.heatmapTexturesCache[key];
                                    this.fullScreenWindowId = windowId;
                                    this.fullScreenEditor   = null;

                                    this.openFullScreen = true;
                                    this.flowEditor.SetDisabled();
                                });
                            }
                        }
                    }
                }
            }
        }
        public override void OnFlowWindow(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 result = new ScreenResult();

                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 rect = window.rect;
                                this.DrawBubble(new Rect(new Vector2(rect.x + rect.width * 0.5f, rect.y), Vector2.zero), 0, window.id, -1, Vector2.zero, "LabelGreen");

                                int value;
                                var keyTransition = string.Format("{0}_{1}", item.serviceName, window.id);
                                if (this.resultsTransitionCache.TryGetValue(keyTransition, out value) == true)
                                {
                                    result.uniqueCount = value;
                                }

                                if (result.uniqueCount > 0 && result.popup == false)
                                {
                                    // Draw exit bubble
                                    this.DrawBubble(new Vector2(rect.x + rect.width * 0.5f, rect.y + rect.height), result, Vector2.zero, "LabelRed", "{1}");
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void OnFlowWindowGUI(FD.FlowWindow window)
        {
            var data = FlowSystem.GetData();

            if (data == null)
            {
                return;
            }

            if (data.modeLayer == ModeLayer.Audio)
            {
                if (window.IsContainer() == true ||
                    window.IsSmall() == true ||
                    window.IsShowDefault() == true)
                {
                    return;
                }

                var screen = window.GetScreen();
                if (screen != null)
                {
                    GUILayout.BeginHorizontal();
                    {
                        var playType = (int)screen.audio.playType;
                        playType = GUILayoutExt.Popup(playType, new string[2] {
                            "Keep Current", "Replace"
                        }, FlowSystemEditorWindow.defaultSkin.label, GUILayout.Width(EditorGUIUtility.labelWidth));
                        screen.audio.playType = (UnityEngine.UI.Windows.Audio.Window.PlayType)playType;

                        var rect = GUILayoutUtility.GetLastRect();

                        /*var newId = */ AudioPopupEditor.Draw(new Rect(rect.x + rect.width, rect.y, window.rect.width - EditorGUIUtility.labelWidth - 10f, rect.height), screen.audio.id, (result) => {
                            screen.audio.id    = result;
                            window.audioEditor = null;
                        }, screen.audio.clipType, screen.audio.flowData.audio, null);

                        /*if (newId != screen.audio.id) {
                         *
                         *      screen.audio.id = newId;
                         *      window.audioEditor = null;
                         *
                         * }*/
                    }
                    GUILayout.EndHorizontal();

                    var state = data.audio.GetState(screen.audio.clipType, screen.audio.id);
                    if (state != null && state.clip != null)
                    {
                        GUILayout.BeginVertical();
                        {
                            GUILayout.Box(string.Empty, FlowSystemEditorWindow.styles.layoutBoxStyle, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                            var rect = GUILayoutUtility.GetLastRect();

                            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) == true)
                            {
                                window.audioEditor = null;
                            }

                            if (window.audioEditor == null)
                            {
                                EditorPrefs.SetBool("AutoPlayAudio", false);
                                window.audioEditor = Editor.CreateEditor(state.clip);
                                //System.Type.GetType("AudioUtil").InvokeMember("StopClip", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, null, null, new object[] { state.clip });
                            }

                            if (Event.current.type != EventType.MouseDrag && Event.current.type != EventType.DragPerform)
                            {
                                window.audioEditor.OnPreviewGUI(rect, EditorStyles.helpBox);
                                GUILayout.BeginHorizontal();
                                window.audioEditor.OnPreviewSettings();
                                GUILayout.EndHorizontal();
                            }
                        }
                        GUILayout.EndVertical();
                    }
                }
            }
        }
        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; });
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }