Esempio n. 1
0
        // Find menus from command id
        private static void LoadMenuFromCommandId(IList menus, Dictionary <string, MenuItemScriptCommand> menuItems, string prefix = "")
        {
            if (menus == null || menuItems == null)
            {
                return;
            }

            foreach (var menuData in menus)
            {
                if (menuData != null)
                {
                    var menu = menuData as JSONObject;
                    if (menu == null)
                    {
                        continue;
                    }
                    var isInternal = JsonUtils.JsonReadBoolean(menu, k_MenuKeyInternal);
                    if (isInternal && !Unsupported.IsDeveloperMode())
                    {
                        continue;
                    }
                    var menuName     = JsonUtils.JsonReadString(menu, k_MenuKeyName);
                    var fullMenuName = prefix + menuName;

                    var platform = JsonUtils.JsonReadString(menu, k_MenuKeyPlatform);

                    // Check the menu item platform
                    if (!String.IsNullOrEmpty(platform) && !Application.platform.ToString().ToLowerInvariant().StartsWith(platform.ToLowerInvariant()))
                    {
                        continue;
                    }

                    // Check if we are a submenu
                    if (menu.Contains(k_MenuKeyChildren))
                    {
                        if (menu[k_MenuKeyChildren] is IList children)
                        {
                            LoadMenuFromCommandId(children, menuItems, fullMenuName + "/");
                        }
                    }
                    else
                    {
                        var commandId = JsonUtils.JsonReadString(menu, k_MenuKeyCommandId);
                        if (!String.IsNullOrEmpty(commandId) && CommandService.Exists(commandId))
                        {
                            // Create a new menu item pointing to a command handler
                            var shortcut = JsonUtils.JsonReadString(menu, k_MenuKeyShortcut);
                            var @checked = JsonUtils.JsonReadBoolean(menu, k_MenuKeyChecked);

                            var validateCommandId = JsonUtils.JsonReadString(menu, k_MenuKeyValidateCommandId);
                            var commandMenuItem   = MenuItemScriptCommand.InitializeFromCommand(fullMenuName, 100, commandId, validateCommandId);
                            menuItems[fullMenuName] = commandMenuItem;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        void OnEnable()
        {
            MakeSureConsoleAlwaysOnlyOne();

            titleContent     = GetLocalizedTitleContent();
            ms_ConsoleWindow = this;
            m_DevBuild       = Unsupported.IsDeveloperMode();

            Constants.LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2);
        }
        void OnInspectorUpdate()
        {
            string miniOverview = UnityEditorInternal.ProfilerDriver.miniMemoryOverview;

            if (Unsupported.IsDeveloperMode() && m_LastMiniMemoryOverview != miniOverview)
            {
                m_LastMiniMemoryOverview = miniOverview;
                Repaint();
            }
        }
Esempio n. 4
0
        private void OnInspectorUpdate()
        {
            string miniMemoryOverview = ProfilerDriver.miniMemoryOverview;

            if (Unsupported.IsDeveloperMode() && this.m_LastMiniMemoryOverview != miniMemoryOverview)
            {
                this.m_LastMiniMemoryOverview = miniMemoryOverview;
                base.Repaint();
            }
        }
Esempio n. 5
0
 internal static SettingsProvider CreateUnityServicesProvider()
 {
     if (Unsupported.IsDeveloperMode() || UnityConnect.preferencesEnabled)
     {
         var settings = new PreferencesProvider("Preferences/Unity Services");
         settings.guiHandler = searchContext => { OnGUI(searchContext, settings.ShowUnityConnectPrefs); };
         return(settings);
     }
     return(null);
 }
        public override void FetchData()
        {
            m_RootItem = new TreeViewItem(System.Int32.MaxValue, 0, null, "Invisible Root Item");
            SetExpanded(m_RootItem, true); // ensure always visible

            // We want three roots: Favorites, Assets, and Saved Filters
            List <TreeViewItem> visibleRoots = new List <TreeViewItem>();

            // Fetch asset folders
            int          assetsFolderInstanceID = GetAssetsFolderInstanceID();
            int          depth         = 0;
            string       displayName   = "Assets"; //CreateDisplayName (assetsFolderInstanceID);
            TreeViewItem assetRootItem = new TreeViewItem(assetsFolderInstanceID, depth, m_RootItem, displayName);

            ReadAssetDatabase(HierarchyType.Assets, assetRootItem, depth + 1);

            // Fetch packages
            TreeViewItem packagesRootItem = null;

            if (Unsupported.IsDeveloperMode() && EditorPrefs.GetBool("ShowPackagesFolder"))
            {
                var    packagesFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetPackagesMountPoint());
                string packagesDisplayName      = AssetDatabase.GetPackagesMountPoint();
                packagesRootItem = new TreeViewItem(packagesFolderInstanceID, depth, m_RootItem, packagesDisplayName);
                ReadAssetDatabase(HierarchyType.Packages, packagesRootItem, depth + 1);
            }

            // Fetch saved filters
            TreeViewItem savedFiltersRootItem = SavedSearchFilters.ConvertToTreeView();

            savedFiltersRootItem.parent = m_RootItem;

            // Order
            visibleRoots.Add(savedFiltersRootItem);
            visibleRoots.Add(assetRootItem);

            if (packagesRootItem != null)
            {
                visibleRoots.Add(packagesRootItem);
            }

            m_RootItem.children = visibleRoots;

            // Get global expanded state of roots
            foreach (TreeViewItem item in m_RootItem.children)
            {
                bool expanded = EditorPrefs.GetBool(kProjectBrowserString + item.displayName, true);
                SetExpanded(item, expanded);
            }

            m_NeedRefreshRows = true;
        }
Esempio n. 7
0
        void OnInspectorUpdate()
        {
            string miniOverview   = UnityEditorInternal.ProfilerDriver.miniMemoryOverview;
            string bakeModeString = GetBakeModeString();

            if ((Unsupported.IsDeveloperMode() && m_MiniMemoryOverview != miniOverview) || (m_BakeModeString != bakeModeString))
            {
                m_MiniMemoryOverview = miniOverview;
                m_BakeModeString     = bakeModeString;

                Repaint();
            }
        }
Esempio n. 8
0
        protected void OnInspectorUpdate()
        {
            string miniOverview      = UnityEditorInternal.ProfilerDriver.miniMemoryOverview;
            bool?  autoLightBakingOn = GetBakeMode();

            if ((Unsupported.IsDeveloperMode() && m_MiniMemoryOverview != miniOverview) || (m_autoLightBakingOn != autoLightBakingOn))
            {
                m_MiniMemoryOverview = miniOverview;
                m_autoLightBakingOn  = autoLightBakingOn;

                Repaint();
            }
        }
Esempio n. 9
0
        internal void OnEnable()
        {
            if (m_ConsoleAttachToPlayerState == null)
            {
                m_ConsoleAttachToPlayerState = new ConsoleAttachToPlayerState(this);
            }

            titleContent     = GetLocalizedTitleContent();
            ms_ConsoleWindow = this;
            m_DevBuild       = Unsupported.IsDeveloperMode();

            Constants.LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2);
        }
Esempio n. 10
0
 protected virtual void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow window)
 {
     if (menu.GetItemCount() != 0)
     {
         menu.AddSeparator("");
     }
     if (Unsupported.IsDeveloperMode())
     {
         menu.AddItem(EditorGUIUtility.TrTextContent("Inspect Window", null, null), false, new GenericMenu.MenuFunction2(this.Inspect), window);
         menu.AddItem(EditorGUIUtility.TrTextContent("Inspect View", null, null), false, new GenericMenu.MenuFunction2(this.Inspect), window.m_Parent);
         menu.AddItem(EditorGUIUtility.TrTextContent("Reload Window _f5", null, null), false, new GenericMenu.MenuFunction2(this.Reload), window);
         menu.AddSeparator("");
     }
 }
Esempio n. 11
0
            protected override void OnGUIMenu(Rect connectRect, List <ProfilerChoise> profilers)
            {
                if (this.additionalMenuItems == null)
                {
                    this.additionalMenuItems = new List <string>();
                    this.additionalMenuItems.Add("Player Logging");
                    if (Unsupported.IsDeveloperMode())
                    {
                        this.additionalMenuItems.Add("Full Log (Developer Mode Only)");
                    }
                    this.additionalMenuItems.Add("");
                }
                IEnumerable <string> source = this.additionalMenuItems.Concat(from p in profilers
                                                                              select p.Name);
                List <bool> list = new List <bool>();

                list.Add(true);
                List <int> list2 = new List <int>();
                bool       flag  = ScriptableSingleton <PlayerConnectionLogReceiver> .instance.State != PlayerConnectionLogReceiver.ConnectionState.Disconnected;

                if (flag)
                {
                    list2.Add(0);
                    if (Unsupported.IsDeveloperMode())
                    {
                        if (ScriptableSingleton <PlayerConnectionLogReceiver> .instance.State == PlayerConnectionLogReceiver.ConnectionState.FullLog)
                        {
                            list2.Add(1);
                        }
                        list.Add(true);
                    }
                    list.Add(true);
                    list.AddRange(from p in profilers
                                  select p.Enabled);
                }
                else
                {
                    list.AddRange(new bool[source.Count <string>() - 1]);
                }
                int num = profilers.FindIndex((ProfilerChoise p) => p.IsSelected());

                if (num != -1)
                {
                    list2.Add(num + this.additionalMenuItems.Count);
                }
                bool[] array = new bool[list.Count];
                array[this.additionalMenuItems.Count - 1] = true;
                EditorUtility.DisplayCustomMenuWithSeparators(connectRect, source.ToArray <string>(), list.ToArray(), array, list2.ToArray(), new EditorUtility.SelectMenuItemFunction(this.SelectClick), profilers);
            }
Esempio n. 12
0
        public override void AddItemsToMenu(GenericMenu menu)
        {
            menu.AddItem(EditorGUIUtility.TrTextContent("Normal"), m_InspectorMode == InspectorMode.Normal, SetNormal);
            menu.AddItem(EditorGUIUtility.TrTextContent("Debug"), m_InspectorMode == InspectorMode.Debug, SetDebug);

            if (Unsupported.IsDeveloperMode())
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Debug-Internal"), m_InspectorMode == InspectorMode.DebugInternal, SetDebugInternal);
                menu.AddItem(EditorGUIUtility.TrTextContent("Use UI Toolkit Default Inspector"), useUIElementsDefaultInspector, SetUseUIEDefaultInspector);
            }

            m_LockTracker.AddItemsToMenu(menu);
            menu.AddSeparator(String.Empty);
            base.AddItemsToMenu(menu);
        }
Esempio n. 13
0
 public void InvokeOnGUI(Rect onGUIPosition)
 {
     if (Unsupported.IsDeveloperMode() && this.actualView != null && Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.F5)
     {
         this.Reload(this.actualView);
     }
     else
     {
         base.DoWindowDecorationStart();
         GUIStyle gUIStyle = "dockareaoverlay";
         if (this.actualView is GameView)
         {
             GUI.Box(onGUIPosition, GUIContent.none, gUIStyle);
         }
         HostView.BeginOffsetArea(new Rect(onGUIPosition.x + 2f, onGUIPosition.y + 17f, onGUIPosition.width - 4f, onGUIPosition.height - 17f - 2f), GUIContent.none, "TabWindowBackground");
         EditorGUIUtility.ResetGUIState();
         bool flag = false;
         try
         {
             this.Invoke("OnGUI");
         }
         catch (TargetInvocationException ex)
         {
             if (ex.InnerException is ExitGUIException)
             {
                 flag = true;
             }
             throw;
         }
         finally
         {
             if (!flag)
             {
                 if (this.actualView != null && this.actualView.m_FadeoutTime != 0f && Event.current != null && Event.current.type == EventType.Repaint)
                 {
                     this.actualView.DrawNotification();
                 }
                 HostView.EndOffsetArea();
                 EditorGUIUtility.ResetGUIState();
                 base.DoWindowDecorationEnd();
                 if (Event.current.type == EventType.Repaint)
                 {
                     gUIStyle.Draw(onGUIPosition, GUIContent.none, 0);
                 }
             }
         }
     }
 }
Esempio n. 14
0
        protected virtual void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow window)
        {
            if (menu.GetItemCount() != 0)
            {
                menu.AddSeparator("");
            }

            if (window && Unsupported.IsDeveloperMode())
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Inspect Window"), false, Inspect, window);
                menu.AddItem(EditorGUIUtility.TrTextContent("Inspect View"), false, Inspect, window.m_Parent);
                menu.AddItem(EditorGUIUtility.TrTextContent("Reload Window _f5"), false, Reload, window);

                menu.AddSeparator("");
            }
        }
Esempio n. 15
0
        internal void OnEnable()
        {
            if (m_ConsoleAttachToPlayerState == null)
            {
                m_ConsoleAttachToPlayerState = new ConsoleAttachToPlayerState(this);
            }

            // Update the filter on enable for DomainReload(keep current filter) and window opening(reset filter because m_searchText is null)
            SetFilter(LogEntries.GetFilteringText());

            titleContent     = GetLocalizedTitleContent();
            ms_ConsoleWindow = this;
            m_DevBuild       = Unsupported.IsDeveloperMode();

            Constants.LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2);
        }
        void ShowRealtimeLMGUI(Renderer renderer)
        {
            EditorGUI.indentLevel += 1;

            Hash128 inputSystemHash = new Hash128();

            if (renderer != null && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash))
            {
                ShowRealtimeLightmapPreview(inputSystemHash);
            }

            int instWidth, instHeight;

            if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight))
            {
                EditorGUILayout.LabelField(Styles.RealtimeLMInstanceResolution, GUIContent.Temp(instWidth.ToString() + "x" + instHeight.ToString()));
            }

            int width, height;

            if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height))
            {
                EditorGUILayout.LabelField(Styles.RealtimeLMResolution, GUIContent.Temp(width.ToString() + "x" + height.ToString()));
            }

            if (Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash))
                {
                    EditorGUILayout.LabelField(Styles.RealtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString()));
                }

                Hash128 geometryHash;
                if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash))
                {
                    EditorGUILayout.LabelField(Styles.RealtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString()));
                }

                EditorGUILayout.LabelField(Styles.RealtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString()));
            }

            EditorGUI.indentLevel -= 1;
        }
Esempio n. 17
0
        bool IsEditorConnectionTargeted(EditorConnectionTarget connection)
        {
            switch (connection)
            {
            case EditorConnectionTarget.None:
            case EditorConnectionTarget.MainEditorProcessPlaymode:
                return(ProfilerDriver.profileEditor == false);

            case EditorConnectionTarget.MainEditorProcessEditmode:
                return(ProfilerDriver.profileEditor == true);

            default:
                if (Unsupported.IsDeveloperMode())
                {
                    Debug.LogError($"{connection} is not implemented!");
                }
                return(ProfilerDriver.profileEditor == false);
            }
        }
Esempio n. 18
0
        private void DrawRefreshStatus()
        {
            bool compiling        = EditorApplication.isCompiling;
            bool assembliesLocked = !EditorApplication.CanReloadAssemblies();

            if (compiling || showProgress)
            {
                if (assembliesLocked)
                {
                    GUILayout.Button(Styles.assemblyLock, Styles.statusIcon);
                }
                else
                {
                    int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f);
                    GUILayout.Button(Styles.statusWheel[frame], Styles.statusIcon);
                }
            }
            else
            {
                if (GUILayout.Button(Styles.progressIcon, Styles.statusIcon))
                {
                    Progress.ShowDetails();
                }

                var buttonRect = GUILayoutUtility.GetLastRect();
                EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link);
            }

            GUILayout.Space(Styles.spacing);

            if (Unsupported.IsBleedingEdgeBuild())
            {
                var backup = GUI.color;
                GUI.color = Color.yellow;
                GUILayout.Label("THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD");
                GUI.color = backup;
            }
            else if (Unsupported.IsDeveloperMode())
            {
                GUILayout.Label(m_MiniMemoryOverview, Styles.statusLabel);
                EditorGUIUtility.CleanCache(m_MiniMemoryOverview);
            }
        }
Esempio n. 19
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            bool anyUxmlImported = false;
            bool anyUssImported  = false;

            foreach (string assetPath in importedAssets)
            {
                if (assetPath.EndsWith("uss"))
                {
                    if (!anyUssImported)
                    {
                        anyUssImported = true;
                        FlagStyleSheetChange();
                    }
                }
                else if (assetPath.EndsWith("uxml"))
                {
                    if (!anyUxmlImported)
                    {
                        anyUxmlImported = true;
                        UIElementsViewImporter.logger.FinishImport();

                        // the inline stylesheet cache might get out of date.
                        // Usually called by the USS importer, which might not get called here
                        StyleSheetCache.ClearCaches();

                        if (UxmlLiveReloadIsEnabled && Unsupported.IsDeveloperMode())
                        {
                            // Delay the view reloading so we do not try to reload the view that
                            // is currently active in the current callstack (i.e. ProjectView).
                            EditorApplication.update += OneShotUxmlLiveReload;
                        }
                    }
                }

                // no need to continue, as we found both extensions we were looking for
                if (anyUxmlImported && anyUssImported)
                {
                    break;
                }
            }
        }
Esempio n. 20
0
        public PreviewRenderUtility()
        {
            m_PreviewScene = new PreviewScene("Preview Scene");

            var l0 = CreateLight();

            previewScene.AddGameObject(l0);
            Light0 = l0.GetComponent <Light>();

            var l1 = CreateLight();

            previewScene.AddGameObject(l1);
            Light1 = l1.GetComponent <Light>();

            Light0.color = SceneView.kSceneViewFrontLight;
            Light1.transform.rotation = Quaternion.Euler(340, 218, 177);
            Light1.color = new Color(.4f, .4f, .45f, 0f) * .7f;

            m_PixelPerfect = false;

            // Set a default background color
            defaultBackgroundColor = new Color(49.0f / 255.0f, 49.0f / 255.0f, 49.0f / 255.0f, 1.0f);
            colorSpace             = QualitySettings.activeColorSpace;
            camera.backgroundColor = colorSpace == ColorSpace.Gamma ? defaultBackgroundColor : defaultBackgroundColor.linear;

            if (Unsupported.IsDeveloperMode())
            {
                var stackTrace = new StackTrace();
                for (int i = 0; i < stackTrace.FrameCount; i++)
                {
                    var frame = stackTrace.GetFrame(i);
                    var type  = frame.GetMethod().DeclaringType;
                    if (type != null && (type.IsSubclassOf(typeof(Editor)) || type.IsSubclassOf(typeof(EditorWindow))))
                    {
                        m_Type = type.Name;
                        break;
                    }
                }
            }

            m_previewOpened = false;
        }
        private void DrawMiscTab()
        {
            if (Unsupported.IsDeveloperMode() || PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(Style.devOptions
                                                                                 , PhysicsVisualizationSettings.devOptions);
            }

            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider(Style.dotAlpha
                                                                               , PhysicsVisualizationSettings.dotAlpha, -1f, 1f);

                PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(Style.forceDot
                                                                               , PhysicsVisualizationSettings.forceDot);

                Tools.hidden = EditorGUILayout.Toggle(Style.toolsHidden
                                                      , Tools.hidden);
            }
        }
Esempio n. 22
0
 public void DeveloperBuildSettingsGUI()
 {
     if (Unsupported.IsDeveloperMode())
     {
         Lightmapping.concurrentJobsType        = (Lightmapping.ConcurrentJobsType)EditorGUILayout.IntPopup(LightingWindowBakeSettings.Styles.ConcurrentJobs, (int)Lightmapping.concurrentJobsType, LightingWindowBakeSettings.Styles.ConcurrentJobsTypeStrings, LightingWindowBakeSettings.Styles.ConcurrentJobsTypeValues, new GUILayoutOption[0]);
         Lightmapping.enlightenForceUpdates     = EditorGUILayout.Toggle(LightingWindowBakeSettings.Styles.ForceUpdates, Lightmapping.enlightenForceUpdates, new GUILayoutOption[0]);
         Lightmapping.enlightenForceWhiteAlbedo = EditorGUILayout.Toggle(LightingWindowBakeSettings.Styles.ForceWhiteAlbedo, Lightmapping.enlightenForceWhiteAlbedo, new GUILayoutOption[0]);
         Lightmapping.filterMode = (FilterMode)EditorGUILayout.EnumPopup(EditorGUIUtility.TempContent("Filter Mode"), Lightmapping.filterMode, new GUILayoutOption[0]);
         EditorGUILayout.Slider(this.m_BounceScale, 0f, 10f, LightingWindowBakeSettings.Styles.BounceScale, new GUILayoutOption[0]);
         EditorGUILayout.Slider(this.m_UpdateThreshold, 0f, 1f, LightingWindowBakeSettings.Styles.UpdateThreshold, new GUILayoutOption[0]);
         if (GUILayout.Button("Clear disk cache", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             Lightmapping.Clear();
             Lightmapping.ClearDiskCache();
         }
         if (GUILayout.Button("Print state to console", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             Lightmapping.PrintStateToConsole();
         }
         if (GUILayout.Button("Reset albedo/emissive", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             GIDebugVisualisation.ResetRuntimeInputTextures();
         }
         if (GUILayout.Button("Reset environment", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             DynamicGI.UpdateEnvironment();
         }
     }
 }
Esempio n. 23
0
        void AllocationCallstacksToolbarItem()
        {
            if (Unsupported.IsDeveloperMode())
            {
                bool toggled        = m_SelectedMemRecordMode != ProfilerMemoryRecordMode.None;
                var  oldToggleState = toggled;
                if (EditorGUILayout.DropDownToggle(ref toggled, Styles.recordCallstacks, EditorStyles.toolbarDropDownToggle))
                {
                    Rect     rect  = GUILayoutUtility.topLevel.GetLast();
                    string[] names = new string[]
                    {
                        L10n.Tr("None"), L10n.Tr("Managed Allocations")
                    };
                    if (Unsupported.IsDeveloperMode())
                    {
                        names = new string[]
                        {
                            L10n.Tr("None"), L10n.Tr("Managed Allocations"), L10n.Tr("All Allocations (fast)"), L10n.Tr("All Allocations (full)")
                        };
                    }

                    var enabled = new bool[names.Length];
                    for (int c = 0; c < names.Length; ++c)
                    {
                        enabled[c] = true;
                    }
                    var selected = new int[] { (int)m_SelectedMemRecordMode };
                    EditorUtility.DisplayCustomMenu(rect, names, enabled, selected, MemRecordModeClick, null);
                    GUIUtility.ExitGUI();
                }
                if (toggled != oldToggleState)
                {
                    m_SelectedMemRecordMode = (m_SelectedMemRecordMode != ProfilerMemoryRecordMode.None) ? ProfilerMemoryRecordMode.None :
                                              (m_LastSelectedMemRecordMode == ProfilerMemoryRecordMode.None ? ProfilerMemoryRecordMode.ManagedAllocations : m_LastSelectedMemRecordMode);
                }
            }
            else
            {
                m_SelectedMemRecordMode = GUILayout.Toggle(m_SelectedMemRecordMode == ProfilerMemoryRecordMode.ManagedAllocations, Styles.recordCallstacks, EditorStyles.toolbarButton) ? ProfilerMemoryRecordMode.ManagedAllocations : ProfilerMemoryRecordMode.None;
            }
        }
Esempio n. 24
0
        void OnTargetedEditorConnectionChanged(EditorConnectionTarget change)
        {
            switch (change)
            {
            case EditorConnectionTarget.None:
            case EditorConnectionTarget.MainEditorProcessPlaymode:
                ProfilerDriver.profileEditor = false;
                break;

            case EditorConnectionTarget.MainEditorProcessEditmode:
                ProfilerDriver.profileEditor = true;
                break;

            default:
                ProfilerDriver.profileEditor = false;
                if (Unsupported.IsDeveloperMode())
                {
                    Debug.LogError($"{change} is not implemented!");
                }
                break;
            }
        }
Esempio n. 25
0
 private void DrawSpecialModeLabel()
 {
     if (Unsupported.IsBleedingEdgeBuild())
     {
         GUILayout.Space(k_SpaceBeforeProgress);
         m_SpecialModeLabel = "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD";
         var backup = GUI.color;
         GUI.color = Color.yellow;
         GUILayout.Label(m_SpecialModeLabel);
         GUI.color = backup;
     }
     else if (Unsupported.IsDeveloperMode())
     {
         GUILayout.Space(k_SpaceBeforeProgress);
         m_SpecialModeLabel = m_MiniMemoryOverview;
         GUILayout.Label(m_SpecialModeLabel, Styles.statusLabel);
         EditorGUIUtility.CleanCache(m_MiniMemoryOverview);
     }
     else
     {
         m_SpecialModeLabel = "";
     }
 }
        public override void FetchData()
        {
            this.m_RootItem = new TreeViewItem(2147483647, 0, null, "Invisible Root Item");
            this.SetExpanded(this.m_RootItem, true);
            List <TreeViewItem> list            = new List <TreeViewItem>();
            int          assetsFolderInstanceID = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID();
            int          num          = 0;
            string       displayName  = "Assets";
            TreeViewItem treeViewItem = new TreeViewItem(assetsFolderInstanceID, num, this.m_RootItem, displayName);

            this.ReadAssetDatabase(HierarchyType.Assets, treeViewItem, num + 1);
            TreeViewItem treeViewItem2 = null;

            if (Unsupported.IsDeveloperMode() && EditorPrefs.GetBool("ShowPackagesFolder"))
            {
                int    mainAssetOrInProgressProxyInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetPackagesMountPoint());
                string packagesMountPoint = AssetDatabase.GetPackagesMountPoint();
                treeViewItem2 = new TreeViewItem(mainAssetOrInProgressProxyInstanceID, num, this.m_RootItem, packagesMountPoint);
                this.ReadAssetDatabase(HierarchyType.Packages, treeViewItem2, num + 1);
            }
            TreeViewItem treeViewItem3 = SavedSearchFilters.ConvertToTreeView();

            treeViewItem3.parent = this.m_RootItem;
            list.Add(treeViewItem3);
            list.Add(treeViewItem);
            if (treeViewItem2 != null)
            {
                list.Add(treeViewItem2);
            }
            this.m_RootItem.children = list;
            foreach (TreeViewItem current in this.m_RootItem.children)
            {
                bool @bool = EditorPrefs.GetBool(ProjectBrowserColumnOneTreeViewDataSource.kProjectBrowserString + current.displayName, true);
                this.SetExpanded(current, @bool);
            }
            this.m_NeedRefreshRows = true;
        }
Esempio n. 27
0
        void ShowRealtimeLMGUI(Renderer renderer)
        {
            Hash128 inputSystemHash;

            if (renderer == null || !Lightmapping.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128())
            {
                return; // early return since we don't have any lightmaps for it
            }
            if (!UpdateRealtimeTexture(inputSystemHash, renderer.GetInstanceID()))
            {
                return;
            }

            m_ShowRealtimeLM.value = EditorGUILayout.Foldout(m_ShowRealtimeLM.value, Styles.realtimeLM, true);

            if (!m_ShowRealtimeLM.value)
            {
                return;
            }

            EditorGUI.indentLevel += 1;

            GUILayout.BeginHorizontal();

            DrawLightmapPreview(m_CachedRealtimeTexture.texture, true, renderer.GetInstanceID());

            GUILayout.BeginVertical();

            int instWidth, instHeight;

            if (Lightmapping.GetInstanceResolution(renderer, out instWidth, out instHeight))
            {
                GUILayout.Label(Styles.realtimeLMInstanceResolution.text + ": " + instWidth + "x" + instHeight);
            }

            int width, height;

            if (Lightmapping.GetSystemResolution(renderer, out width, out height))
            {
                GUILayout.Label(Styles.realtimeLMResolution.text + ": " + width + "x" + height);
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                if (Lightmapping.GetInstanceHash(renderer, out instanceHash))
                {
                    EditorGUILayout.LabelField(Styles.realtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString()));
                }

                Hash128 geometryHash;
                if (Lightmapping.GetGeometryHash(renderer, out geometryHash))
                {
                    EditorGUILayout.LabelField(Styles.realtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString()));
                }

                EditorGUILayout.LabelField(Styles.realtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString()));
            }

            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }
Esempio n. 28
0
        public void InvokeOnGUI(Rect onGUIPosition, Rect viewRect)
        {
            // Handle window reloading.
            if (Unsupported.IsDeveloperMode() &&
                actualView != null &&
                Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.F5)
            {
                if (Event.current.control)
                {
                    DebugWindow(actualView);
                }
                else
                {
                    Reload(actualView);
                }
                return;
            }

            DoWindowDecorationStart();

            BeginOffsetArea(viewRect, GUIContent.none, "TabWindowBackground");

            EditorGUIUtility.ResetGUIState();

            bool isExitGUIException = false;

            try
            {
                using (new PerformanceTracker(actualView.GetType().Name + ".OnGUI." + Event.current.type))
                {
                    Invoke("OnGUI");
                }
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException is ExitGUIException)
                {
                    isExitGUIException = true;
                }
                throw;
            }
            finally
            {
                // We can't reset gui state after ExitGUI we just want to bail completely
                if (!isExitGUIException)
                {
                    CheckNotificationStatus();

                    EndOffsetArea();

                    EditorGUIUtility.ResetGUIState();

                    DoWindowDecorationEnd();

                    if (Event.current != null && Event.current.type == EventType.Repaint)
                    {
                        HostViewStyles.overlay.Draw(onGUIPosition, GUIContent.none, 0);
                    }
                }
            }
        }
Esempio n. 29
0
        void ShowAtlasGUI(int instanceID, bool isMeshRenderer)
        {
            if (m_LightmapIndex == null)
            {
                return;
            }

            Hash128 contentHash = LightmapVisualizationUtility.GetBakedGITextureHash(m_LightmapIndex.intValue, 0, GITextureType.Baked);

            // if we need to fetch a new texture
            if (m_CachedBakedTexture.texture == null || m_CachedBakedTexture.contentHash != contentHash)
            {
                m_CachedBakedTexture = LightmapVisualizationUtility.GetBakedGITexture(m_LightmapIndex.intValue, 0, GITextureType.Baked);
            }

            if (m_CachedBakedTexture.texture == null)
            {
                return;
            }

            m_ShowBakedLM.value = EditorGUILayout.Foldout(m_ShowBakedLM.value, Styles.atlas, true);

            if (!m_ShowBakedLM.value)
            {
                return;
            }

            EditorGUI.indentLevel += 1;

            GUILayout.BeginHorizontal();

            DrawLightmapPreview(m_CachedBakedTexture.texture, false, instanceID);

            GUILayout.BeginVertical();

            GUILayout.Label(Styles.atlasIndex.text + ": " + m_LightmapIndex.intValue);
            GUILayout.Label(Styles.atlasTilingX.text + ": " + m_LightmapTilingOffsetX.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasTilingY.text + ": " + m_LightmapTilingOffsetY.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasOffsetX.text + ": " + m_LightmapTilingOffsetZ.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasOffsetY.text + ": " + m_LightmapTilingOffsetW.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));

            var settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();

            float lightmapResolution = settings.lightmapResolution * CalcLODScale(isMeshRenderer) * m_LightmapScale.floatValue;

            if (isMeshRenderer && (m_Renderers != null) && (m_Renderers.Length > 0))
            {
                Transform transform           = m_Renderers[0].GetComponent <Transform>();
                float     lightmapObjectScale = System.Math.Min(System.Math.Min(transform.localScale.x, transform.localScale.y), transform.localScale.z);
                GUILayout.Label(Styles.lightmapResolution.text + ": " + lightmapResolution.ToString(CultureInfo.InvariantCulture.NumberFormat));
                GUILayout.Label(Styles.lightmapObjectScale.text + ": " + lightmapObjectScale.ToString(CultureInfo.InvariantCulture.NumberFormat));
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            bool showProgressiveInfo = isPrefabAsset || (settings.bakedGI && settings.lightmapper != LightingSettings.Lightmapper.Enlighten);

            if (showProgressiveInfo && Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                Lightmapping.GetPVRInstanceHash(instanceID, out instanceHash);
                EditorGUILayout.LabelField(Styles.pvrInstanceHash, GUIContent.Temp(instanceHash.ToString()));

                Hash128 atlasHash;
                Lightmapping.GetPVRAtlasHash(instanceID, out atlasHash);
                EditorGUILayout.LabelField(Styles.pvrAtlasHash, GUIContent.Temp(atlasHash.ToString()));

                int atlasInstanceOffset;
                Lightmapping.GetPVRAtlasInstanceOffset(instanceID, out atlasInstanceOffset);
                EditorGUILayout.LabelField(Styles.pvrAtlasInstanceOffset, GUIContent.Temp(atlasInstanceOffset.ToString()));
            }
            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }
Esempio n. 30
0
        private static void LoadMenu(IList menus, string prefix = "", int priority = 100)
        {
            const string k_MenuKeyName              = "name";
            const string k_MenuKeyItemId            = "menu_item_id";
            const string k_MenuKeyCommandId         = "command_id";
            const string k_MenuKeyValidateCommandId = "validate_command_id";
            const string k_MenuKeyChildren          = "children";
            const string k_MenuKeyPriority          = "priority";
            const string k_MenuKeyInternal          = "internal";
            const string k_MenuKeyShortcut          = "shortcut";
            const string k_MenuKeyChecked           = "checked";
            const string k_MenuKeyPlatform          = "platform";
            const string k_MenuKeyRename            = "rename";

            if (menus == null)
            {
                return;
            }

            foreach (var menuData in menus)
            {
                if (menuData != null)
                {
                    var menu = menuData as JSONObject;
                    if (menu == null)
                    {
                        continue;
                    }
                    var isInternal = JsonUtils.JsonReadBoolean(menu, k_MenuKeyInternal);
                    if (isInternal && !Unsupported.IsDeveloperMode())
                    {
                        continue;
                    }
                    var menuName            = JsonUtils.JsonReadString(menu, k_MenuKeyName);
                    var fullMenuName        = prefix + menuName;
                    var platform            = JsonUtils.JsonReadString(menu, k_MenuKeyPlatform);
                    var hasExplicitPriority = menu.Contains(k_MenuKeyPriority);
                    priority = JsonUtils.JsonReadInt(menu, k_MenuKeyPriority, priority + 1);

                    // Check the menu item platform
                    if (!String.IsNullOrEmpty(platform) && !Application.platform.ToString().ToLowerInvariant().StartsWith(platform.ToLowerInvariant()))
                    {
                        continue;
                    }

                    // Check if we are a submenu
                    if (menu.Contains(k_MenuKeyChildren))
                    {
                        if (menu[k_MenuKeyChildren] is IList)
                        {
                            LoadMenu(menu[k_MenuKeyChildren] as IList, fullMenuName + "/", priority);
                        }
                        else if (menu[k_MenuKeyChildren] is string && (string)menu[k_MenuKeyChildren] == "*")
                        {
                            var whitelistedItems = Menu.ExtractSubmenus(fullMenuName);
                            var renamedTo        = prefix + JsonUtils.JsonReadString(menu, k_MenuKeyRename, menuName);
                            foreach (var wi in whitelistedItems)
                            {
                                Menu.AddExistingMenuItem(wi.Replace(fullMenuName, renamedTo), wi, hasExplicitPriority ? priority : -1);
                            }
                        }
                    }
                    else
                    {
                        var commandId = JsonUtils.JsonReadString(menu, k_MenuKeyCommandId);
                        if (String.IsNullOrEmpty(commandId))
                        {
                            // We are re-using a default menu item
                            var menuItemId = JsonUtils.JsonReadString(menu, k_MenuKeyItemId, fullMenuName);
                            if (fullMenuName.Contains('/'))
                            {
                                Menu.AddExistingMenuItem(fullMenuName, menuItemId, priority);
                            }
                        }
                        else if (CommandService.Exists(commandId))
                        {
                            // Create a new menu item pointing to a command handler
                            var shortcut = JsonUtils.JsonReadString(menu, k_MenuKeyShortcut);
                            var @checked = JsonUtils.JsonReadBoolean(menu, k_MenuKeyChecked);

                            Func <bool> validateHandler   = null;
                            var         validateCommandId = JsonUtils.JsonReadString(menu, k_MenuKeyValidateCommandId);
                            if (!String.IsNullOrEmpty(validateCommandId))
                            {
                                validateHandler = () => (bool)CommandService.Execute(validateCommandId, CommandHint.Menu | CommandHint.Validate);
                            }

                            Menu.AddMenuItem(fullMenuName, shortcut, @checked, priority, () => CommandService.Execute(commandId, CommandHint.Menu), validateHandler);
                        }
                    }
                }
                else
                {
                    priority += 100;
                }
            }
        }