void SetUpFileMenu()
        {
            m_FileMenu.menu.AppendAction("New", a =>
            {
                NewDocument();
            });

            if (Unsupported.IsDeveloperMode())
            {
                m_FileMenu.menu.AppendAction("New (Test)", a =>
                {
                    NewTestDocument();
                });
            }

            m_FileMenu.menu.AppendSeparator();

            m_FileMenu.menu.AppendAction("Save", a =>
            {
                PromptSaveDocumentDialog();
            });
            m_FileMenu.menu.AppendAction("Save As...", a =>
            {
                PromptSaveAsDocumentDialog();
            });

            m_FileMenu.menu.AppendSeparator();

            m_FileMenu.menu.AppendAction("Open...", a =>
            {
                var path = OpenLoadFileDialog(BuilderConstants.ToolbarLoadUxmlDialogTitle, BuilderConstants.Uxml);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                var appPath = Application.dataPath;
                if (path.StartsWith(appPath))
                {
                    path = "Assets/" + path.Substring(appPath.Length);
                }
                else
                {
                    Debug.LogError(BuilderConstants.ToolbarCannotLoadUxmlOutsideProjectMessage);
                    return;
                }

                var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(path);
                if (asset == null)
                {
                    Debug.LogError(BuilderConstants.ToolbarSelectedAssetIsInvalidMessage);
                    return;
                }

                LoadDocument(asset);
            });
        }
예제 #2
0
 public static void StorePanelPrefs()
 {
     if (Unsupported.IsDeveloperMode() || UnityConnect.preferencesEnabled)
     {
         foreach (KeyValuePair <string, UnityConnectPrefs.CloudPanelPref> current in UnityConnectPrefs.m_CloudPanelPref)
         {
             current.Value.StoreCloudServicePref();
         }
     }
 }
예제 #3
0
        void SetUpFileMenu()
        {
            m_FileMenu.menu.AppendAction("New", a =>
            {
                NewDocument();
            });

            if (Unsupported.IsDeveloperMode())
            {
                m_FileMenu.menu.AppendAction("New (Test)", a =>
                {
                    NewTestDocument();
                });

                m_FileMenu.menu.AppendAction("New (Test Variables)", a =>
                {
                    NewTestVariablesDocument();
                });
            }

            m_FileMenu.menu.AppendAction("Open...", a =>
            {
                var path = OpenLoadFileDialog(BuilderConstants.ToolbarLoadUxmlDialogTitle, BuilderConstants.Uxml);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                var appPath = Application.dataPath;
                if (path.StartsWith(appPath))
                {
                    path = "Assets/" + path.Substring(appPath.Length);
                }
                else
                {
                    Debug.LogError(BuilderConstants.ToolbarCannotLoadUxmlOutsideProjectMessage);
                    return;
                }

                var asset = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(path);

                LoadDocument(asset, false, false, path);
            });

            m_FileMenu.menu.AppendSeparator();

            m_FileMenu.menu.AppendAction("Save", a =>
            {
                SaveDocument(false);
            });
            m_FileMenu.menu.AppendAction("Save As...", a =>
            {
                SaveDocument(true);
            });
        }
예제 #4
0
        public static void StorePanelPrefs()
        {
            if (!Unsupported.IsDeveloperMode() && !UnityConnect.preferencesEnabled)
            {
                return;
            }

            foreach (KeyValuePair <string, CloudPanelPref> kvp in m_CloudPanelPref)
            {
                kvp.Value.StoreCloudServicePref();
            }
        }
        public override void OnActivate(string searchContext, VisualElement rootElement)
        {
            // TODO: Switch to use uxml/uss for this.
            var root = new VisualElement();

            rootElement.Add(root);
            var title = new Label(Title);

            title.style.unityFontStyleAndWeight = FontStyle.Bold;
            title.style.marginTop      = 1;
            title.style.fontSize       = 19;
            title.style.unityTextAlign = TextAnchor.MiddleLeft;
            title.style.height         = 26;
            root.Add(title);

            Resources.Templates.Settings.AddStyles(rootElement);
            foreach (var kvp in s_Settings)
            {
                if (kvp.Value.All(w => w.Internal) && !Unsupported.IsDeveloperMode())
                {
                    continue;
                }

                var label = new Label {
                    text = kvp.Key
                };
                label.style.unityFontStyleAndWeight = FontStyle.Bold;
                root.Add(label);

                foreach (var wrapper in kvp.Value)
                {
                    if (wrapper.Internal && !Unsupported.IsDeveloperMode())
                    {
                        continue;
                    }

                    var setting = wrapper.Setting;
                    var element = new PropertyElement();
                    element.style.marginLeft = -3;
                    element.SetAttributeFilter(AttributeFilter);
                    element.SetTarget(setting);
                    element.OnChanged += (propertyElement, path) => setting.OnSettingChanged(path);
                    root.Add(element);
                    element.RegisterCallback <GeometryChangedEvent>(evt =>
                                                                    StylingUtility.AlignInspectorLabelWidth(element));
                }
            }
            root.AddToClassList("unity-inspector-element");
            root.style.paddingLeft = 10;

            base.OnActivate(searchContext, rootElement);
        }
        public override IEnumerable <IPluginHandler> GetCompilationPluginHandlers(CompilationOptions getCompilationOptions)
        {
            foreach (var compilationPluginHandler in base.GetCompilationPluginHandlers(getCompilationOptions))
            {
                yield return(compilationPluginHandler);
            }
            yield return(new DotsBoundObjectPlugin());

            if (Unsupported.IsDeveloperMode())
            {
                yield return(new GenerateNodeDocPlugin());
            }
        }
예제 #7
0
        public override void OnBeginSetting()
        {
            base.OnBeginSetting();

            GameObject main = GameObject.Find("HTFramework");

            if (main)
            {
                _main = main.GetComponent <Main>();
            }

            _isDeveloperMode = Unsupported.IsDeveloperMode();
        }
예제 #8
0
        public override void OnBeginSetting()
        {
            base.OnBeginSetting();

            GameObject main = GameObject.Find("HTFramework");

            if (main)
            {
                _main = main.GetComponent <Main>();
            }

            _isDeveloperMode  = Unsupported.IsDeveloperMode();
            _isEnableLnkTools = EditorPrefs.GetBool(EditorPrefsTable.LnkTools_Enable, true);
        }
 public override void OnGUI(string searchContext)
 {
     EditorGUIUtility.labelWidth     = 300;
     ProfilerUserSettings.frameCount = EditorGUILayout.IntSlider(Content.k_FrameCountText, ProfilerUserSettings.frameCount, ProfilerUserSettings.kMinFrameCount, ProfilerUserSettings.kMaxFrameCount);
     if (ProfilerUserSettings.frameCount > 600)
     {
         EditorGUILayout.HelpBox(Content.k_FrameCountWarningText);
     }
     if (Unsupported.IsDeveloperMode() || Unsupported.IsSourceBuild())
     {
         ProfilerUserSettings.useOutOfProcessProfiler =
             EditorGUILayout.Toggle(Content.k_EnableOutOfProcessProfiler, ProfilerUserSettings.useOutOfProcessProfiler);
     }
 }
예제 #10
0
        public void OnAdvancedMenuCreate(DropdownMenu menu)
        {
            if (!Unsupported.IsDeveloperMode())
            {
                return;
            }

            menu.AppendSeparator();
            menu.AppendAction("Internal/Always show development tools", a =>
            {
                OnDevelopmentToolToggle();
            }, a => !Unsupported.IsDeveloperMode() ? DropdownMenuAction.Status.Hidden :
                              AlwaysShowDevTools?DropdownMenuAction.Status.Checked: DropdownMenuAction.Status.Normal);
        }
예제 #11
0
        public void OnWindowCreated(WindowCreatedArgs args)
        {
            m_DevelopMenu         = args.window.AddPackageActionMenu();
            m_DevelopMenu.text    = L10n.Tr("Develop");
            m_DevelopMenu.visible = false;

            m_EmbedDropdown        = m_DevelopMenu.AddDropdownItem();
            m_EmbedDropdown.text   = L10n.Tr("Copy to Packages folder");
            m_EmbedDropdown.action = EmbedClicked;

            m_CloneDropdown         = m_DevelopMenu.AddDropdownItem();
            m_CloneDropdown.text    = L10n.Tr("Clone from git repo");
            m_CloneDropdown.action  = CloneClicked;
            m_CloneDropdown.visible = Unsupported.IsDeveloperMode();
        }
        public static void AddCustomMenu(ITelemetry instance, GenericMenu menu)
        {
            if (!Unsupported.IsDeveloperMode())
            {
                return;
            }

            menu.AddItem(new GUIContent($"Open {GetName(instance)}"), false, () =>
            {
                var wnd = CreateWindow <TelemetryWindow>();

                wnd.Initialize(instance);
                wnd.Show();
            });
        }
예제 #13
0
        public AutomatedWindow(T windowToDrive)
        {
            m_EditorWindow = windowToDrive;
            //TODO: find a way to properly pass this data from the runner here.
            isAutomationVisible = EditorPrefs.GetBool("UnityEditor.PlaymodeTestsRunnerWindow" + ".visualizeUIAutomationEvents", false);

            //TODO: at the moment you can only debug one GUIView at a time, and nothing prevents from someone else to change who's being debugged.
            //figure out a way to handle this.
            GUIViewDebuggerHelper.DebugWindow(m_EditorWindow.m_Parent);
            GUIViewDebuggerHelper.onViewInstructionsChanged += m_Model.ViewContentsChanged;
            m_EditorWindow.RepaintImmediately(); //will create all the instructions, and will trigger onViewInstructionsChanged

            m_Disposed       = false;
            m_DeveloperBuild = Unsupported.IsDeveloperMode();
        }
예제 #14
0
        static Texture2D LoadIcon(string resourcePath, bool autoScale = false)
        {
            if (string.IsNullOrEmpty(resourcePath))
            {
                return(null);
            }

            if (EditorGUIUtility.isProSkin)
            {
                var dirName           = Path.GetDirectoryName(resourcePath).Replace('\\', '/');
                var fileName          = Path.GetFileName(resourcePath);
                var darkSkinVariation = string.Format("{0}/d_{1}", dirName, fileName);
                if (File.Exists(darkSkinVariation))
                {
                    resourcePath = darkSkinVariation;
                }
            }

            float systemScale = EditorGUIUtility.pixelsPerPoint;

            if (autoScale && systemScale > 1f)
            {
                int    scale    = Mathf.RoundToInt(systemScale);
                string dirName  = Path.GetDirectoryName(resourcePath).Replace('\\', '/');
                string fileName = Path.GetFileNameWithoutExtension(resourcePath);
                string fileExt  = Path.GetExtension(resourcePath);
                for (int s = scale; scale > 1; --scale)
                {
                    string scaledResourcePath = string.Format("{0}/{1}@{2}x{3}", dirName, fileName, s, fileExt);
                    var    scaledResource     = AssetDatabase.LoadAssetAtPath <Texture2D>(scaledResourcePath);// EditorResources.Load<Texture2D>(scaledResourcePath, Unsupported.IsDeveloperMode());
                    if (scaledResource != null)
                    {
                        return(scaledResource);
                    }
                    else if (Unsupported.IsDeveloperMode())
                    {
                        Debug.LogWarningFormat("Couldn't load scaled Icon asset at path: {0}", scaledResourcePath);
                    }
                }
            }
            var resource = AssetDatabase.LoadAssetAtPath <Texture2D>(resourcePath);//EditorResources.Load<Texture2D>(resourcePath, Unsupported.IsDeveloperMode()); if (Unsupported.IsDeveloperMode())

            if (Unsupported.IsDeveloperMode() && resource == null)
            {
                Debug.LogErrorFormat("Couldn't load Icon asset at path: {0}", resourcePath);
            }
            return(resource);
        }
예제 #15
0
 private static void CreateDynamicMenuItems()
 {
     if (Unsupported.IsDeveloperMode())
     {
         Menu.AddMenuItem(
             "Jobs/Burst/Clear JIT Cache",
             "",
             false,
             1001, // Add at bottom of Burst menu, below standard items which have default priority of 1000
             () =>
         {
             BurstEditorUtility.RequestClearJitCache();
             EditorUtility.RequestScriptReload();
         },
             () => !EditorApplication.isPlayingOrWillChangePlaymode);
     }
 }
        bool AudioDeepProfileToggle()
        {
            int toggleFlags = (int)ProfilerCaptureFlags.Channels;

            if (Unsupported.IsDeveloperMode())
            {
                toggleFlags |= (int)ProfilerCaptureFlags.Clips | (int)ProfilerCaptureFlags.DSPNodes;
            }
            ProfilerAudioPopupItems oldShowDetailedAudioPane = (AudioSettings.profilerCaptureFlags & toggleFlags) != 0 ? ProfilerAudioPopupItems.Detailed : ProfilerAudioPopupItems.Simple;
            ProfilerAudioPopupItems newShowDetailedAudioPane = (ProfilerAudioPopupItems)EditorGUILayout.EnumPopup(oldShowDetailedAudioPane, EditorStyles.toolbarDropDownLeft, GUILayout.Width(70f));

            if (oldShowDetailedAudioPane != newShowDetailedAudioPane)
            {
                ProfilerDriver.SetAudioCaptureFlags((AudioSettings.profilerCaptureFlags & ~toggleFlags) | (newShowDetailedAudioPane == ProfilerAudioPopupItems.Detailed ? toggleFlags : 0));
            }
            return((AudioSettings.profilerCaptureFlags & toggleFlags) != 0);
        }
예제 #17
0
        protected virtual void BuildOptionMenu(GenericMenu menu)
        {
            var prefs = m_CommandDispatcher.State.Preferences;

            if (prefs != null)
            {
                if (Unsupported.IsDeveloperMode())
                {
                    menu.AddItem(new GUIContent("Show Searcher in Regular Window"),
                                 prefs.GetBool(BoolPref.SearcherInRegularWindow),
                                 () =>
                    {
                        prefs.ToggleBool(BoolPref.SearcherInRegularWindow);
                    });

                    menu.AddSeparator("");

                    menu.AddItem(new GUIContent("Reload Graph"), false, () =>
                    {
                        if (m_CommandDispatcher.State?.WindowState.GraphModel != null)
                        {
                            var openedGraph        = m_CommandDispatcher.State.WindowState.CurrentGraph;
                            Selection.activeObject = null;
                            Resources.UnloadAsset((Object)m_CommandDispatcher.State.WindowState.AssetModel);
                            m_CommandDispatcher.Dispatch(
                                new LoadGraphAssetCommand(openedGraph.GetGraphAssetModelPath(),
                                                          openedGraph.AssetLocalId, m_GraphView.Window.PluginRepository));
                        }
                    });

                    menu.AddItem(new GUIContent("Rebuild GraphView"), false, () =>
                    {
                        using (var updater = m_CommandDispatcher.State.GraphViewState.UpdateScope)
                        {
                            updater.ForceCompleteUpdate();
                        }
                    });
                    menu.AddItem(new GUIContent("Rebuild Blackboard"), false, () =>
                    {
                        m_GraphView.GetBlackboard()?.BuildUI();
                        m_GraphView.GetBlackboard()?.UpdateFromModel();
                    });
                }
            }
        }
예제 #18
0
        public static int GetServiceEnv(string serviceName)
        {
            if (Unsupported.IsDeveloperMode() || UnityConnect.preferencesEnabled)
            {
                return(EditorPrefs.GetInt(ServicePrefKey(kSvcEnvPref, serviceName)));
            }

            for (var i = 0; i < kEnvironmentFamilies.Length; i++)
            {
                var environmentName = kEnvironmentFamilies[i];
                //By using the configuration it should default to production if there is no
                //-cloudEnvironment or to the switch value in case it is specified
                if (environmentName.Equals(UnityConnect.instance.configuration, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(i);
                }
            }
            return(0); //Return production if there is an error
        }
 static void DisplayPorts(Stencil stencil, IEnumerable <IPortModel> ports)
 {
     EditorGUI.indentLevel++;
     foreach (var port in ports)
     {
         string details = port.PortType + " ( " + port.DataType.GetMetadata(stencil).FriendlyName + " )";
         EditorGUILayout.LabelField(port.UniqueId, details);
         if (Unsupported.IsDeveloperMode())
         {
             EditorGUI.indentLevel++;
             foreach (IEdgeModel edgeModel in port.GraphModel.GetEdgesConnections(port))
             {
                 int edgeIndex = edgeModel.GraphModel.EdgeModels.IndexOf(edgeModel);
                 EditorGUILayout.LabelField(edgeIndex.ToString(), edgeModel.OutputPortModel.ToString());
                 EditorGUILayout.LabelField("to", edgeModel.InputPortModel.ToString());
             }
             EditorGUI.indentLevel--;
         }
     }
     EditorGUI.indentLevel--;
 }
        public override void OnActivate(string searchContext, VisualElement rootElement)
        {
            var builderTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.SettingsUIPath + "/BuilderSettingsView.uxml");

            builderTemplate.CloneTree(rootElement);

            var styleSheet = BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(BuilderConstants.SettingsUIPath + "/BuilderSettingsView.uss");

            rootElement.styleSheets.Add(styleSheet);

            var editorExtensionsModeToggle = rootElement.Q <Toggle>(k_EditorExtensionsModeToggleName);

            editorExtensionsModeToggle.SetValueWithoutNotify(BuilderProjectSettings.enableEditorExtensionModeByDefault);
            editorExtensionsModeToggle.RegisterValueChangedCallback(e =>
            {
                BuilderProjectSettings.enableEditorExtensionModeByDefault = e.newValue;
            });

            var zoomToggle = rootElement.Q <Toggle>(k_DisableMouseWheelZoomingToggleName);

            zoomToggle.SetValueWithoutNotify(BuilderProjectSettings.disableMouseWheelZooming);
            zoomToggle.RegisterValueChangedCallback(e =>
            {
                BuilderProjectSettings.disableMouseWheelZooming = e.newValue;
            });

            var absolutePlacementToggle = rootElement.Q <Toggle>(k_EnableAbsolutePositionPlacementToggleName);

            absolutePlacementToggle.SetValueWithoutNotify(BuilderProjectSettings.enableAbsolutePositionPlacement);
            absolutePlacementToggle.RegisterValueChangedCallback(e =>
            {
                BuilderProjectSettings.enableAbsolutePositionPlacement = e.newValue;
            });
            if (!Unsupported.IsDeveloperMode())
            {
                absolutePlacementToggle.style.display = DisplayStyle.None;
            }

            base.OnActivate(searchContext, rootElement);
        }
예제 #21
0
        public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
        {
            if (evt.target is Node)
            {
                var canViewShader = node.hasPreview || node is IMasterNode;
                evt.menu.AppendAction("Copy Shader", CopyToClipboard,
                                      _ => canViewShader ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Hidden,
                                      GenerationMode.ForReals);
                evt.menu.AppendAction("Show Generated Code", ShowGeneratedCode,
                                      _ => canViewShader ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Hidden,
                                      GenerationMode.ForReals);

                if (Unsupported.IsDeveloperMode())
                {
                    evt.menu.AppendAction("Show Preview Code", ShowGeneratedCode,
                                          _ => canViewShader ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Hidden,
                                          GenerationMode.Preview);
                }
            }

            base.BuildContextualMenu(evt);
        }
        private DocumentationPackageManagerUI(VisualTreeAsset asset)
        {
#if UNITY_2019_1_OR_NEWER
            root = asset.CloneTree();
            var    resourcesRoot = "packages/com.unity.package-manager-doctools/Editor/Resources/";
            string path          = EditorGUIUtility.isProSkin ? resourcesRoot + "Styles/Dark.uss" : resourcesRoot + "Styles/Light.uss";
            var    styleSheet    = EditorGUIUtility.Load(path) as StyleSheet;
            root.styleSheets.Add(styleSheet);
#else
            root = asset.CloneTree(null);
            root.AddStyleSheetPath(EditorGUIUtility.isProSkin ? "Styles/Dark" : "Styles/Light");
#endif
            Add(root);

            if (!Unsupported.IsDeveloperMode())
            {
                Verbose.visible = false;
            }

            GenerateButton.clickable.clicked += GenerateDocClick;
            Verbose.RegisterValueChangedCallback(evt => VerbosityToggle());
            VerbosityToggle();
        }
예제 #23
0
        public static int GetServiceEnv(string serviceName)
        {
            int result;

            if (Unsupported.IsDeveloperMode() || UnityConnect.preferencesEnabled)
            {
                result = EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelServer", serviceName));
            }
            else
            {
                for (int i = 0; i < UnityConnectPrefs.kEnvironmentFamilies.Length; i++)
                {
                    string text = UnityConnectPrefs.kEnvironmentFamilies[i];
                    if (text.Equals(UnityConnect.instance.configuration, StringComparison.InvariantCultureIgnoreCase))
                    {
                        result = i;
                        return(result);
                    }
                }
                result = 0;
            }
            return(result);
        }
예제 #24
0
        public Object GetActualExportObject(Object obj)
        {
            if (!obj)
            {
                return(null);
            }

            var path = AssetDatabase.GetAssetPath(obj);

            if (path.StartsWith("Packages/", StringComparison.Ordinal))
            {
                path = path.Substring("Packages/".Length);
                var indexOfSlash = path.IndexOf("/", StringComparison.Ordinal);
                var packageName  = path.Substring(0, indexOfSlash);
                path = "Packages/" + packageName;

                if (!Unsupported.IsDeveloperMode())
                {
                    // sanitize: do not allow uploading packages that are in the Library
                    var libraryRoot = Path.GetFullPath(Application.dataPath + "/../Library");
                    if (Path.GetFullPath(path).StartsWith(libraryRoot, StringComparison.Ordinal))
                    {
                        return(null);
                    }

                    // sanitize: do not allow re-uploading of Unity-scoped packages
                    if (packageName.StartsWith("com.unity.", StringComparison.OrdinalIgnoreCase))
                    {
                        return(null);
                    }
                }
                return(AssetDatabase.LoadAssetAtPath <DefaultAsset>(path));
            }

            return(obj);
        }
예제 #25
0
        static BuildAnalyticsTypes.ContextInfo CreateContextInfo(BuildResult result)
        {
            var ci = new BuildAnalyticsTypes.ContextInfo();

#if UNITY_INTERNAL
            ci.internal_build = true;
#else
            ci.internal_build = Unsupported.IsDeveloperMode();
#endif

            if (result == null)
            {
                return(ci);
            }

            if (!result.BuildConfiguration.TryGetComponent <DotsRuntimeBuildProfile>(out var profile))
            {
                return(ci);
            }

            ci.configuration = profile.Configuration.ToString();
            ci.platform      = profile.Target.UnityPlatformName;
            return(ci);
        }
        internal void DoGUI()
        {
            if (m_State.Behavior == MemoryViewerBehavior.Hidden)
            {
                return;
            }

            var splitterRectVertical   = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.Height(5));
            var splitterRectHorizontal = new Rect(m_State.MemoryWindowWidth, splitterRectVertical.y, 5, m_State.MemoryWindowHeight);

            DoSplitter(splitterRectVertical, splitterRectHorizontal);
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(m_State.MemoryWindowWidth), GUILayout.Height(m_State.MemoryWindowHeight));

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Group:");
            EditorGUI.BeginChangeCheck();
            m_State.MemoryGroup = (MemoryGroup)EditorGUILayout.EnumPopup(m_State.MemoryGroup);
            if (EditorGUI.EndChangeCheck())
            {
                UpdateGeneralStats();
            }
            GUILayout.EndHorizontal();

            foreach (var m in GetOrderMemoryTypes())
            {
                DoMemoryToggle(m);
            }

            DoMemoryToggle(MemoryType.Total);

            if (m_State.Behavior == MemoryViewerBehavior.Manual)
            {
                GUILayout.Space(10);
                if (GUILayout.Button("Capture", EditorStyles.miniButton))
                {
                    QueueMemoryRequest(m_ExpectedDevice, m_ExpectedPackageFromRequest);
                }
            }

            if (Unsupported.IsDeveloperMode())
            {
                DoDebuggingGUI();
            }

            GUILayout.EndVertical();
            var rc = GUILayoutUtility.GetLastRect();


            GUILayout.BeginVertical();
            // Note: GUILayoutUtility.GetRect must be called for Layout event always
            var size = GUILayoutUtility.GetRect(GUIContent.none, AndroidLogcatStyles.internalLogStyle, GUILayout.Height(m_State.MemoryWindowHeight));

            size.height -= 4;


            if (m_EntryCount > 0)
            {
                DoEntriesGUI(size);
            }

            DoGuidelinesGUI(size, m_UpperMemoryBoundry);

            if (m_EntryCount > 0)
            {
                DoSelectedStatsGUI(size);
            }

            GUI.Box(new Rect(rc.x + 4, size.y, rc.width - 4, size.height + 1), GUIContent.none, EditorStyles.helpBox);
            GUI.Box(new Rect(size.x, size.y, size.width + 1, size.height + 1), GUIContent.none, EditorStyles.helpBox);

            if (m_ExpectedPackageFromRequest == null)
            {
                EditorGUI.HelpBox(size, "Select a package", MessageType.Info);
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
        }
        public override void DrawView(Rect position)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            ProfilerAudioView newShowDetailedAudioPane = m_ShowDetailedAudioPane;

            if (AudioDeepProfileToggle())
            {
                if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Channels, "Channels", EditorStyles.toolbarButton))
                {
                    newShowDetailedAudioPane = ProfilerAudioView.Channels;
                }
                if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Groups, "Groups", EditorStyles.toolbarButton))
                {
                    newShowDetailedAudioPane = ProfilerAudioView.Groups;
                }
                if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.ChannelsAndGroups, "Channels and groups", EditorStyles.toolbarButton))
                {
                    newShowDetailedAudioPane = ProfilerAudioView.ChannelsAndGroups;
                }
                if (Unsupported.IsDeveloperMode() && GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.DSPGraph, "DSP Graph", EditorStyles.toolbarButton))
                {
                    newShowDetailedAudioPane = ProfilerAudioView.DSPGraph;
                }
                if (Unsupported.IsDeveloperMode() && GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Clips, "Clips", EditorStyles.toolbarButton))
                {
                    newShowDetailedAudioPane = ProfilerAudioView.Clips;
                }
                if (newShowDetailedAudioPane != m_ShowDetailedAudioPane)
                {
                    m_ShowDetailedAudioPane  = newShowDetailedAudioPane;
                    m_LastAudioProfilerFrame = -1; // force update
                }
                if (m_ShowDetailedAudioPane == ProfilerAudioView.DSPGraph)
                {
                    m_ShowInactiveDSPChains = GUILayout.Toggle(m_ShowInactiveDSPChains, "Show inactive", EditorStyles.toolbarButton);
                    if (m_ShowInactiveDSPChains)
                    {
                        m_HighlightAudibleDSPChains = GUILayout.Toggle(m_HighlightAudibleDSPChains, "Highlight audible", EditorStyles.toolbarButton);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    var graphRect = DrawAudioStatsPane(ref m_PaneScroll_AudioDSPLeft);

                    m_PaneScroll_AudioDSPRight = GUI.BeginScrollView(graphRect, m_PaneScroll_AudioDSPRight, new Rect(0, 0, 10000, 20000));

                    var clippingRect = new Rect(m_PaneScroll_AudioDSPRight.x, m_PaneScroll_AudioDSPRight.y, graphRect.width, graphRect.height);

                    if (m_AudioProfilerDSPView == null)
                    {
                        m_AudioProfilerDSPView = new AudioProfilerDSPView();
                    }

                    ProfilerProperty property = m_ProfilerWindow.CreateProperty();
                    if (CheckFrameData(property))
                    {
                        m_AudioProfilerDSPView.OnGUI(clippingRect, property, m_ShowInactiveDSPChains, m_HighlightAudibleDSPChains, ref m_DSPGraphZoomFactor, ref m_PaneScroll_AudioDSPRight);
                    }
                    if (property != null)
                    {
                        property.Dispose();
                    }

                    GUI.EndScrollView();

                    m_ProfilerWindow.Repaint();
                }
                else if (m_ShowDetailedAudioPane == ProfilerAudioView.Clips)
                {
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    var treeRect = DrawAudioStatsPane(ref m_PaneScroll_AudioClips);

                    // TREE
                    if (m_AudioProfilerClipTreeViewState == null)
                    {
                        m_AudioProfilerClipTreeViewState = new AudioProfilerClipTreeViewState();
                    }

                    if (m_AudioProfilerClipViewBackend == null)
                    {
                        m_AudioProfilerClipViewBackend = new AudioProfilerClipViewBackend(m_AudioProfilerClipTreeViewState);
                    }

                    ProfilerProperty property = m_ProfilerWindow.CreateProperty();
                    if (CheckFrameData(property))
                    {
                        var currentFrame = m_ProfilerWindow.GetActiveVisibleFrameIndex();
                        if (currentFrame == -1 || m_LastAudioProfilerFrame != currentFrame)
                        {
                            m_LastAudioProfilerFrame = currentFrame;
                            var sourceItems = property.GetAudioProfilerClipInfo();
                            if (sourceItems != null && sourceItems.Length > 0)
                            {
                                var items = new List <AudioProfilerClipInfoWrapper>();
                                foreach (var s in sourceItems)
                                {
                                    items.Add(new AudioProfilerClipInfoWrapper(s, property.GetAudioProfilerNameByOffset(s.assetNameOffset)));
                                }
                                m_AudioProfilerClipViewBackend.SetData(items);
                                if (m_AudioProfilerClipView == null)
                                {
                                    m_AudioProfilerClipView = new AudioProfilerClipView(m_ProfilerWindow as EditorWindow, m_AudioProfilerClipTreeViewState);
                                    m_AudioProfilerClipView.Init(treeRect, m_AudioProfilerClipViewBackend);
                                }
                            }
                        }
                        if (m_AudioProfilerClipView != null)
                        {
                            m_AudioProfilerClipView.OnGUI(treeRect);
                        }
                    }
                    if (property != null)
                    {
                        property.Dispose();
                    }
                }
                else
                {
                    bool resetAllAudioClipPlayCountsOnPlay = GUILayout.Toggle(AudioUtil.resetAllAudioClipPlayCountsOnPlay, "Reset play count on play", EditorStyles.toolbarButton);
                    if (resetAllAudioClipPlayCountsOnPlay != AudioUtil.resetAllAudioClipPlayCountsOnPlay)
                    {
                        AudioUtil.resetAllAudioClipPlayCountsOnPlay = resetAllAudioClipPlayCountsOnPlay;
                    }
                    if (Unsupported.IsDeveloperMode())
                    {
                        GUILayout.Space(5);
                        bool showAllGroups    = EditorPrefs.GetBool("AudioProfilerShowAllGroups");
                        bool newShowAllGroups = GUILayout.Toggle(showAllGroups, "Show all groups (dev mode only)", EditorStyles.toolbarButton);
                        if (showAllGroups != newShowAllGroups)
                        {
                            EditorPrefs.SetBool("AudioProfilerShowAllGroups", newShowAllGroups);
                        }
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    var treeRect = DrawAudioStatsPane(ref m_PaneScroll_AudioChannels);

                    // TREE
                    if (m_AudioProfilerGroupTreeViewState == null)
                    {
                        m_AudioProfilerGroupTreeViewState = new AudioProfilerGroupTreeViewState();
                    }

                    if (m_AudioProfilerGroupViewBackend == null)
                    {
                        m_AudioProfilerGroupViewBackend = new AudioProfilerGroupViewBackend(m_AudioProfilerGroupTreeViewState);
                    }

                    ProfilerProperty property = m_ProfilerWindow.CreateProperty();
                    if (CheckFrameData(property))
                    {
                        var currentFrame = m_ProfilerWindow.GetActiveVisibleFrameIndex();
                        if (currentFrame == -1 || m_LastAudioProfilerFrame != currentFrame)
                        {
                            m_LastAudioProfilerFrame = currentFrame;
                            var sourceItems = property.GetAudioProfilerGroupInfo();
                            if (sourceItems != null && sourceItems.Length > 0)
                            {
                                var items = new List <AudioProfilerGroupInfoWrapper>();
                                foreach (var s in sourceItems)
                                {
                                    bool isGroup = (s.flags & AudioProfilerGroupInfoHelper.AUDIOPROFILER_FLAGS_GROUP) != 0;
                                    if (m_ShowDetailedAudioPane == ProfilerAudioView.Channels && isGroup)
                                    {
                                        continue;
                                    }
                                    if (m_ShowDetailedAudioPane == ProfilerAudioView.Groups && !isGroup)
                                    {
                                        continue;
                                    }
                                    items.Add(new AudioProfilerGroupInfoWrapper(s, property.GetAudioProfilerNameByOffset(s.assetNameOffset), property.GetAudioProfilerNameByOffset(s.objectNameOffset), m_ShowDetailedAudioPane == ProfilerAudioView.Channels));
                                }
                                m_AudioProfilerGroupViewBackend.SetData(items);
                                if (m_AudioProfilerGroupView == null)
                                {
                                    m_AudioProfilerGroupView = new AudioProfilerGroupView(m_ProfilerWindow as EditorWindow, m_AudioProfilerGroupTreeViewState);
                                    m_AudioProfilerGroupView.Init(treeRect, m_AudioProfilerGroupViewBackend);
                                }
                            }
                        }
                        if (m_AudioProfilerGroupView != null)
                        {
                            m_AudioProfilerGroupView.OnGUI(treeRect, m_ShowDetailedAudioPane == ProfilerAudioView.Channels);
                        }
                    }
                    if (property != null)
                    {
                        property.Dispose();
                    }
                }
            }
            else
            {
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                DrawOverviewText(ProfilerArea.Audio, position);
            }
        }
예제 #28
0
        void DrawOptions()
        {
            if (currentMode.headerState.options == TimelineModeGUIState.Hidden || state.editSequence.asset == null)
            {
                return;
            }

            using (new EditorGUI.DisabledScope(currentMode.headerState.options == TimelineModeGUIState.Disabled))
            {
                var rect = new Rect(position.width - WindowConstants.cogButtonWidth, 0, WindowConstants.cogButtonWidth, WindowConstants.timeAreaYPosition);
                if (EditorGUI.DropdownButton(rect, DirectorStyles.optionsCogIcon, FocusType.Keyboard, EditorStyles.toolbarButton))
                {
                    GenericMenu menu = new GenericMenu();

                    menu.AddItem(EditorGUIUtility.TrTextContent("Preferences Page..."), false, () => SettingsWindow.Show(SettingsScope.User, "Preferences/Timeline"));
                    menu.AddSeparator("");

                    menu.AddItem(EditorGUIUtility.TrTextContent("Seconds"), !state.timeInFrames, ChangeTimeCode, "seconds");
                    menu.AddItem(EditorGUIUtility.TrTextContent("Frames"), state.timeInFrames, ChangeTimeCode, "frames");
                    menu.AddSeparator("");

                    TimeAreaContextMenu.AddTimeAreaMenuItems(menu, state);

                    menu.AddSeparator("");

                    bool standardFrameRate = false;
                    for (int i = 0; i < TimelineProjectSettings.framerateValues.Length; i++)
                    {
                        standardFrameRate |= AddStandardFrameRateMenu(menu, "Frame Rate/" + TimelineProjectSettings.framerateLabels[i], TimelineProjectSettings.framerateValues[i]);
                    }

                    if (standardFrameRate)
                    {
                        menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Frame Rate/Custom"));
                    }
                    else
                    {
                        menu.AddItem(EditorGUIUtility.TrTextContent("Frame Rate/Custom (" + state.editSequence.frameRate + ")"), true, () => {});
                    }

                    menu.AddSeparator("");
                    if (state.playRangeEnabled)
                    {
                        menu.AddItem(EditorGUIUtility.TrTextContent("Play Range Mode/Loop"), state.playRangeLoopMode, () => state.playRangeLoopMode  = true);
                        menu.AddItem(EditorGUIUtility.TrTextContent("Play Range Mode/Once"), !state.playRangeLoopMode, () => state.playRangeLoopMode = false);
                    }
                    else
                    {
                        menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Play Range Mode"));
                    }

                    if (Unsupported.IsDeveloperMode())
                    {
                        menu.AddSeparator("");
                        menu.AddItem(EditorGUIUtility.TrTextContent("Show Snapping Debug"), SnapEngine.displayDebugLayout,
                                     () => SnapEngine.displayDebugLayout = !SnapEngine.displayDebugLayout);

                        menu.AddItem(EditorGUIUtility.TrTextContent("Debug TimeArea"), false,
                                     () =>
                                     Debug.LogFormat("translation: {0}   scale: {1}   rect: {2}   shownRange: {3}", m_TimeArea.translation, m_TimeArea.scale, m_TimeArea.rect, m_TimeArea.shownArea));

                        menu.AddItem(EditorGUIUtility.TrTextContent("Edit Skin"), false, () => Selection.activeObject = DirectorStyles.Instance.customSkin);

                        menu.AddItem(EditorGUIUtility.TrTextContent("Show QuadTree Debugger"), state.showQuadTree,
                                     () => state.showQuadTree = !state.showQuadTree);
                    }

                    menu.DropDown(rect);
                }
            }
        }
예제 #29
0
        void ImportFactoriesFromSource(LibraryTreeItem sourceCategory)
        {
            List <IUxmlFactory>     deferredFactories = new List <IUxmlFactory>();
            FactoryProcessingHelper processingData    = new FactoryProcessingHelper();

            foreach (var factories in VisualElementFactoryRegistry.factories)
            {
                if (factories.Value.Count == 0)
                {
                    continue;
                }

                var factory = factories.Value[0];
                if (!ProcessFactory(factory, processingData))
                {
                    // Could not process the factory now, because it depends on a yet unprocessed factory.
                    // Defer its processing.
                    deferredFactories.Add(factory);
                }
            }

            List <IUxmlFactory> deferredFactoriesCopy;

            do
            {
                deferredFactoriesCopy = new List <IUxmlFactory>(deferredFactories);
                foreach (var factory in deferredFactoriesCopy)
                {
                    deferredFactories.Remove(factory);
                    if (!ProcessFactory(factory, processingData))
                    {
                        // Could not process the factory now, because it depends on a yet unprocessed factory.
                        // Defer its processing again.
                        deferredFactories.Add(factory);
                    }
                }
            }while (deferredFactoriesCopy.Count > deferredFactories.Count);

            if (deferredFactories.Count > 0)
            {
                Debug.Log("Some factories could not be processed because their base type is missing.");
            }

            var categoryStack = new List <LibraryTreeItem>();

            foreach (var known in processingData.knownTypes.Values)
            {
                var split = known.uxmlNamespace.Split('.');

                // Avoid adding our own internal factories (like Package Manager templates).
                if (!Unsupported.IsDeveloperMode() && split.Count() > 0 && s_NameSpacesToAvoid.Contains(split[0]))
                {
                    continue;
                }

                // Avoid adding UI Builder's own types, even in internal mode.
                if (split.Count() >= 3 && split[0] == "Unity" && split[1] == "UI" && split[2] == "Builder")
                {
                    continue;
                }

                AddCategoriesToStack(sourceCategory, categoryStack, split);

                var asset = new VisualElementAsset(known.uxmlQualifiedName);

                var slots     = new Dictionary <string, VisualElement>();
                var overrides = new List <TemplateAsset.AttributeOverride>();
                var vta       = ScriptableObject.CreateInstance <VisualTreeAsset>();
                var context   = new CreationContext(slots, overrides, vta, null);

                var newItem = new LibraryTreeItem(
                    known.uxmlName, () => known.Create(asset, context));
                if (categoryStack.Count == 0)
                {
                    sourceCategory.AddChild(newItem);
                }
                else
                {
                    categoryStack.Last().AddChild(newItem);
                }
            }
        }
        public void Analyze()
        {
            var doSourceCodeAnalysis = Unsupported.IsDeveloperMode();

            var symbolArtifacts   = GetSymbolArtifacts();
            var moduleArtifacts   = GetModuleArtifacts();
            var assemblyArtifacts = GetIl2CPPAssemblyMapArtifacts("Temp/StagingArea/Data/il2cppOutput/Symbols/MethodMap.tsv");

            int moduleAccounted = 0;

            var functionSizes = GetFunctionSizes();

            foreach (var functionSize in functionSizes)
            {
                if (symbolArtifacts.ContainsKey(functionSize.Key))
                {
                    var objectFile = symbolArtifacts[functionSize.Key].Replace('\\', '/');
                    if (doSourceCodeAnalysis)
                    {
                        if (!objectSizes.ContainsKey(objectFile))
                        {
                            objectSizes[objectFile] = 0;
                        }
                        objectSizes[objectFile] += functionSize.Value;
                    }
                    if (objectFile.LastIndexOf('/') != -1)
                    {
                        var objectFolder = objectFile.Substring(0, objectFile.LastIndexOf('/'));
                        if (!folderSizes.ContainsKey(objectFolder))
                        {
                            folderSizes[objectFolder] = 0;
                        }
                        folderSizes[objectFolder] += functionSize.Value;
                    }
                }
                if (moduleArtifacts.ContainsKey(functionSize.Key))
                {
                    var objectFile = moduleArtifacts[functionSize.Key];
                    objectFile = objectFile.Substring(0, objectFile.Length - "Module_Dynamic.bc".Length);
                    objectFile = StrippingInfo.ModuleName(objectFile);

                    if (!moduleSizes.ContainsKey(objectFile))
                    {
                        moduleSizes[objectFile] = 0;
                    }

                    moduleSizes[objectFile] += functionSize.Value;

                    moduleAccounted += functionSize.Value;
                }
                if (assemblyArtifacts.ContainsKey(functionSize.Key))
                {
                    var assembly = assemblyArtifacts[functionSize.Key];
                    if (!assemblySizes.ContainsKey(assembly))
                    {
                        assemblySizes[assembly] = 0;
                    }

                    assemblySizes[assembly] += functionSize.Value;
                }
            }

            AddPlatformSpecificCodeOutputModules();

            int unaccounted = totalSize;

            foreach (var moduleSize in moduleSizes)
            {
                if (modules.Contains(moduleSize.Key))
                {
                    unaccounted -= moduleSize.Value;
                }
            }

            moduleSizes["Unaccounted"] = unaccounted;
            AddModule("Unaccounted", false);
            foreach (var moduleSize in moduleSizes)
            {
                AddModuleSize(moduleSize.Key, moduleSize.Value);
            }

            int totalAssemblySize = 0;

            foreach (var assemblySize in assemblySizes)
            {
                RegisterDependency("IL2CPP Generated", assemblySize.Key);
                sizes[assemblySize.Key] = assemblySize.Value;
                totalAssemblySize      += assemblySize.Value;
                SetIcon(assemblySize.Key, "class/DefaultAsset");
            }
            RegisterDependency("IL2CPP Generated", "IL2CPP Unaccounted");
            sizes["IL2CPP Unaccounted"] = moduleSizes["IL2CPP Generated"] - totalAssemblySize;
            SetIcon("IL2CPP Unaccounted", "class/DefaultAsset");

            if (doSourceCodeAnalysis)
            {
                System.Console.WriteLine("Code size per module: ");
                PrintSizesDictionary(moduleSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per source folder: ");
                PrintSizesDictionary(folderSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per object file: ");
                PrintSizesDictionary(objectSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per function: ");
                PrintSizesDictionary(functionSizes);
                System.Console.WriteLine("\n\n");
            }
        }