InvalidateCache() private method

private InvalidateCache ( ) : void
return void
示例#1
0
        private void OnGUI()
        {
            this.InitStyles();
            if (!WindowPending.s_DidReload)
            {
                WindowPending.s_DidReload = true;
                this.UpdateWindow();
            }
            this.CreateResources();
            Event current     = Event.current;
            float fixedHeight = EditorStyles.toolbar.fixedHeight;

            GUILayout.BeginArea(new Rect(0f, 0f, base.position.width, fixedHeight));
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            int num = (this.incomingList.Root != null) ? this.incomingList.Root.ChildCount : 0;

            this.m_ShowIncoming = !GUILayout.Toggle(!this.m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUIContent content = GUIContent.Temp("Incoming" + ((num != 0) ? (" (" + num.ToString() + ")") : string.Empty));

            this.m_ShowIncoming = GUILayout.Toggle(this.m_ShowIncoming, content, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(Provider.activeTask != null);
            CustomCommand[] customCommands = Provider.customCommands;
            for (int i = 0; i < customCommands.Length; i++)
            {
                CustomCommand customCommand = customCommands[i];
                if (customCommand.context == CommandContext.Global && GUILayout.Button(customCommand.label, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    customCommand.StartTask();
                }
            }
            EditorGUI.EndDisabledGroup();
            bool flag = Mathf.FloorToInt(base.position.width - this.s_ToolbarButtonsWidth) > 0;

            if (flag && GUILayout.Button("Settings", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }
            Color color = GUI.color;

            GUI.color = new Color(1f, 1f, 1f, 0.5f);
            bool flag2 = GUILayout.Button(this.refreshIcon, EditorStyles.toolbarButton, new GUILayoutOption[0]);

            GUI.color = color;
            if (current.isKey && GUIUtility.keyboardControl == 0 && current.type == EventType.KeyDown && current.keyCode == KeyCode.F5)
            {
                flag2 = true;
                current.Use();
            }
            if (flag2)
            {
                Provider.InvalidateCache();
                if (Provider.isActive && Provider.onlineState == OnlineState.Online)
                {
                    Task task = Provider.ChangeSets();
                    task.SetCompletionAction(CompletionAction.OnChangeSetsPendingWindow);
                    Task task2 = Provider.Incoming();
                    task2.SetCompletionAction(CompletionAction.OnIncomingPendingWindow);
                }
                else
                {
                    Provider.UpdateSettings();
                }
            }
            GUILayout.EndArea();
            Rect rect  = new Rect(0f, fixedHeight, base.position.width, base.position.height - fixedHeight - 17f);
            bool flag3 = false;

            GUILayout.EndHorizontal();
            if (!Provider.isActive)
            {
                Color color2 = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = fixedHeight;
                GUILayout.BeginArea(rect);
                GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                string text = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        text      = "CONNECTING...";
                    }
                    else
                    {
                        text = "OFFLINE";
                    }
                }
                GUILayout.Label(text, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }
                GUI.color = color2;
                flag3     = false;
            }
            else
            {
                if (this.m_ShowIncoming)
                {
                    flag3 |= this.incomingList.OnGUI(rect, base.hasFocus);
                }
                else
                {
                    flag3 |= this.pendingList.OnGUI(rect, base.hasFocus);
                }
                rect.y     += rect.height;
                rect.height = 17f;
                GUI.Label(rect, GUIContent.none, WindowPending.s_Styles.bottomBarBg);
                GUIContent content2 = new GUIContent("Apply All Incoming Changes");
                Vector2    vector   = EditorStyles.miniButton.CalcSize(content2);
                Rect       rect2    = new Rect(rect.x, rect.y - 2f, rect.width - vector.x - 5f, rect.height);
                WindowPending.ProgressGUI(rect2, Provider.activeTask, false);
                if (this.m_ShowIncoming)
                {
                    Rect position = rect;
                    position.width  = vector.x;
                    position.height = vector.y;
                    position.y      = rect.y + 2f;
                    position.x      = base.position.width - vector.x - 5f;
                    EditorGUI.BeginDisabledGroup(this.incomingList.Size == 0);
                    if (GUI.Button(position, content2, EditorStyles.miniButton))
                    {
                        Asset item   = new Asset(string.Empty);
                        Task  latest = Provider.GetLatest(new AssetList
                        {
                            item
                        });
                        latest.SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            if (flag3)
            {
                base.Repaint();
            }
        }
        // Editor window GUI paint
        void OnGUI()
        {
            InitStyles();

            if (!s_DidReload)
            {
                s_DidReload = true;
                UpdateWindow();
            }

            CreateResources();

            Event e             = Event.current;
            float toolBarHeight = EditorStyles.toolbar.fixedHeight;
            bool  refresh       = false;

            GUILayout.BeginArea(new Rect(0, 0, position.width, toolBarHeight));


            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            EditorGUI.BeginChangeCheck();

            int incomingChangesetCount = incomingList.Root == null ? 0 : incomingList.Root.ChildCount;

            m_ShowIncoming = !GUILayout.Toggle(!m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton);

            GUIContent cont = GUIContent.Temp("Incoming" + (incomingChangesetCount == 0 ? "" : " (" + incomingChangesetCount.ToString() + ")"));

            m_ShowIncoming = GUILayout.Toggle(m_ShowIncoming, cont, EditorStyles.toolbarButton);

            if (EditorGUI.EndChangeCheck())
            {
                refresh = true;
            }

            GUILayout.FlexibleSpace();

            // Global context custom commands goes here
            using (new EditorGUI.DisabledScope(Provider.activeTask != null))
            {
                foreach (CustomCommand c in Provider.customCommands)
                {
                    if (c.context == CommandContext.Global && GUILayout.Button(c.label, EditorStyles.toolbarButton))
                    {
                        c.StartTask();
                    }
                }
            }

            bool showDeleteEmptyChangesetsButton =
                Mathf.FloorToInt(position.width - s_ToolbarButtonsWidth - s_SettingsButtonWidth - s_DeleteChangesetsButtonWidth) > 0 &&
                HasEmptyPendingChangesets();

            if (showDeleteEmptyChangesetsButton && GUILayout.Button("Delete Empty Changesets", EditorStyles.toolbarButton))
            {
                DeleteEmptyPendingChangesets();
            }

            bool showSettingsButton = Mathf.FloorToInt(position.width - s_ToolbarButtonsWidth - s_SettingsButtonWidth) > 0;

            if (showSettingsButton && GUILayout.Button("Settings", EditorStyles.toolbarButton))
            {
                SettingsService.OpenProjectSettings("Project/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }

            Color origColor = GUI.color;

            GUI.color = new Color(1, 1, 1, 1 * .5f);
            bool refreshButtonClicked = GUILayout.Button(refreshIcon, EditorStyles.toolbarButton);

            refresh   = refresh || refreshButtonClicked;
            GUI.color = origColor;

            if (refresh)
            {
                if (refreshButtonClicked)
                {
                    Provider.InvalidateCache();
                }
                UpdateWindow();
            }

            GUILayout.EndArea();

            Rect rect = new Rect(0, toolBarHeight, position.width, position.height - toolBarHeight - k_BottomBarHeight);

            bool repaint = false;

            GUILayout.EndHorizontal();

            // Disabled Window view
            if (!Provider.isActive)
            {
                Color tmpColor = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = toolBarHeight;
                GUILayout.BeginArea(rect);

                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                GUILayout.FlexibleSpace();
                string msg = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        msg       = "CONNECTING...";
                    }
                    else
                    {
                        msg = "OFFLINE";
                    }
                }

                GUILayout.Label(msg, EditorStyles.miniLabel);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();

                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }

                GUI.color = tmpColor;
                repaint   = false;
            }
            else
            {
                if (m_ShowIncoming)
                {
                    repaint |= incomingList.OnGUI(rect, hasFocus);
                }
                else
                {
                    repaint |= pendingList.OnGUI(rect, hasFocus);
                }


                rect.y     += rect.height;
                rect.height = k_BottomBarHeight;

                // Draw separation line over the button
                GUI.Label(rect, GUIContent.none, s_Styles.bottomBarBg);

                var  content      = EditorGUIUtility.TrTextContent("Apply All Incoming Changes");
                var  buttonSize   = EditorStyles.miniButton.CalcSize(content);
                Rect progressRect = new Rect(rect.x, rect.y - 2, rect.width - buttonSize.x - 5f, rect.height);
                ProgressGUI(progressRect, Provider.activeTask, false);

                if (m_ShowIncoming)
                {
                    // Draw "apply incoming" button
                    var buttonRect = rect;
                    buttonRect.width  = buttonSize.x;
                    buttonRect.height = buttonSize.y;
                    buttonRect.y      = rect.y + 2f;
                    buttonRect.x      = position.width - buttonSize.x - 5f;

                    using (new EditorGUI.DisabledScope(incomingList.Size == 0))
                    {
                        if (GUI.Button(buttonRect, content, EditorStyles.miniButton))
                        {
                            Asset root = new Asset("");
                            Task  t    = Provider.GetLatest(new AssetList()
                            {
                                root
                            });
                            t.SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                        }
                    }
                }
            }

            if (repaint)
            {
                Repaint();
            }
        }
示例#3
0
        private void OnGUI()
        {
            this.InitStyles();
            if (!WindowPending.s_DidReload)
            {
                WindowPending.s_DidReload = true;
                this.UpdateWindow();
            }
            this.CreateResources();
            Event current     = Event.current;
            float fixedHeight = EditorStyles.toolbar.fixedHeight;
            bool  flag1       = false;

            GUILayout.BeginArea(new Rect(0.0f, 0.0f, this.position.width, fixedHeight));
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            int num = this.incomingList.Root != null ? this.incomingList.Root.ChildCount : 0;

            this.m_ShowIncoming = !GUILayout.Toggle(!this.m_ShowIncoming, "Outgoing", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_ShowIncoming = GUILayout.Toggle(this.m_ShowIncoming, GUIContent.Temp("Incoming" + (num != 0 ? " (" + num.ToString() + ")" : string.Empty)), EditorStyles.toolbarButton, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                flag1 = true;
            }
            GUILayout.FlexibleSpace();
            EditorGUI.BeginDisabledGroup(Provider.activeTask != null);
            foreach (CustomCommand customCommand in Provider.customCommands)
            {
                if (customCommand.context == CommandContext.Global && GUILayout.Button(customCommand.label, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    customCommand.StartTask();
                }
            }
            EditorGUI.EndDisabledGroup();
            if (Mathf.FloorToInt(this.position.width - this.s_ToolbarButtonsWidth - this.s_SettingsButtonWidth - this.s_DeleteChangesetsButtonWidth) > 0 && this.HasEmptyPendingChangesets() && GUILayout.Button("Delete Empty Changesets", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                this.DeleteEmptyPendingChangesets();
            }
            if (Mathf.FloorToInt(this.position.width - this.s_ToolbarButtonsWidth - this.s_SettingsButtonWidth) > 0 && GUILayout.Button("Settings", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Editor");
                EditorWindow.FocusWindowIfItsOpen <InspectorWindow>();
                GUIUtility.ExitGUI();
            }
            Color color1 = GUI.color;

            GUI.color = new Color(1f, 1f, 1f, 0.5f);
            bool flag2 = GUILayout.Button((Texture)this.refreshIcon, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            bool flag3 = flag1 || flag2;

            GUI.color = color1;
            if (current.isKey && GUIUtility.keyboardControl == 0 && (current.type == EventType.KeyDown && current.keyCode == KeyCode.F5))
            {
                flag3 = true;
                current.Use();
            }
            if (flag3)
            {
                if (flag2)
                {
                    Provider.InvalidateCache();
                }
                this.UpdateWindow();
            }
            GUILayout.EndArea();
            Rect rect  = new Rect(0.0f, fixedHeight, this.position.width, (float)((double)this.position.height - (double)fixedHeight - 17.0));
            bool flag4 = false;

            GUILayout.EndHorizontal();
            bool flag5;

            if (!Provider.isActive)
            {
                Color color2 = GUI.color;
                GUI.color   = new Color(0.8f, 0.5f, 0.5f);
                rect.height = fixedHeight;
                GUILayout.BeginArea(rect);
                GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                string text = "DISABLED";
                if (Provider.enabled)
                {
                    if (Provider.onlineState == OnlineState.Updating)
                    {
                        GUI.color = new Color(0.8f, 0.8f, 0.5f);
                        text      = "CONNECTING...";
                    }
                    else
                    {
                        text = "OFFLINE";
                    }
                }
                GUILayout.Label(text, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                rect.y += rect.height;
                if (!string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.Label(rect, Provider.offlineReason);
                }
                GUI.color = color2;
                flag5     = false;
            }
            else
            {
                flag5       = !this.m_ShowIncoming ? flag4 | this.pendingList.OnGUI(rect, this.hasFocus) : flag4 | this.incomingList.OnGUI(rect, this.hasFocus);
                rect.y     += rect.height;
                rect.height = 17f;
                GUI.Label(rect, GUIContent.none, WindowPending.s_Styles.bottomBarBg);
                GUIContent content = new GUIContent("Apply All Incoming Changes");
                Vector2    vector2 = EditorStyles.miniButton.CalcSize(content);
                WindowPending.ProgressGUI(new Rect(rect.x, rect.y - 2f, (float)((double)rect.width - (double)vector2.x - 5.0), rect.height), Provider.activeTask, false);
                if (this.m_ShowIncoming)
                {
                    Rect position = rect;
                    position.width  = vector2.x;
                    position.height = vector2.y;
                    position.y      = rect.y + 2f;
                    position.x      = (float)((double)this.position.width - (double)vector2.x - 5.0);
                    EditorGUI.BeginDisabledGroup(this.incomingList.Size == 0);
                    if (GUI.Button(position, content, EditorStyles.miniButton))
                    {
                        Asset     asset  = new Asset(string.Empty);
                        AssetList assets = new AssetList();
                        assets.Add(asset);
                        Provider.GetLatest(assets).SetCompletionAction(CompletionAction.OnGotLatestPendingWindow);
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            if (!flag5)
            {
                return;
            }
            this.Repaint();
        }