예제 #1
0
        private static void OnProgress(int current, int total)
        {
            // OnProgress is called from a background thread,
            // but we need to update the progress UI on the main thread.
            EditorApplication.CallDelayed(() =>
            {
                if (current == total)
                {
                    // We've finished - remove progress bar.
                    if (Progress.Exists(BurstProgressId))
                    {
                        Progress.Remove(BurstProgressId);
                        BurstProgressId = -1;
                    }
                }
                else
                {
                    // Do we need to create the progress bar?
                    if (!Progress.Exists(BurstProgressId))
                    {
                        BurstProgressId = Progress.Start(
                            "Burst",
                            "Compiling...",
                            Progress.Options.Unmanaged);
                    }

                    Progress.Report(
                        BurstProgressId,
                        current / (float)total,
                        $"Compiled {current} / {total} methods");
                }
            });
        }
예제 #2
0
        private void OnDisable()
        {
            if (m_CloseBehaviour == ActionSelected.Cancel)
            {
                m_ConflictResolver.Cancel();
            }

            EditorApplication.UnlockReloadAssemblies();

            //We need to delay this action, since actions can depend on the right view having focus, and when closing a window
            //that will change the current focused view to null.
            EditorApplication.CallDelayed(() => {
                m_PreviouslyFocusedView?.Focus();

                switch (m_CloseBehaviour)
                {
                case ActionSelected.ExecuteAlways:
                    m_ConflictResolver.ExecuteAlways(m_SelectedEntry);
                    break;

                case ActionSelected.ExecuteOnce:
                    m_ConflictResolver.ExecuteOnce(m_SelectedEntry);
                    break;
                }
            }, 0f);
        }
 public void OnTreeSelectionChanged(int[] selection)
 {
     if (selection.Length == 1)
     {
         AudioProfilerGroupTreeViewItem item2 = this.m_TreeView.FindItem(selection[0]) as AudioProfilerGroupTreeViewItem;
         if (item2 != null)
         {
             EditorGUIUtility.PingObject(item2.info.info.assetInstanceId);
             this.delayedPingObject = item2.info.info.objectInstanceId;
             EditorApplication.CallDelayed(new EditorApplication.CallbackFunction(this.PingObjectDelayed), 1f);
         }
     }
 }
예제 #4
0
 public void OnTreeSelectionChanged(int[] selection)
 {
     if (selection.Length == 1)
     {
         TreeViewItem treeViewItem = this.m_TreeView.FindItem(selection[0]);
         AudioProfilerView.AudioProfilerTreeViewItem audioProfilerTreeViewItem = treeViewItem as AudioProfilerView.AudioProfilerTreeViewItem;
         if (audioProfilerTreeViewItem != null)
         {
             EditorGUIUtility.PingObject(audioProfilerTreeViewItem.info.info.assetInstanceId);
             this.delayedPingObject = audioProfilerTreeViewItem.info.info.objectInstanceId;
             EditorApplication.CallDelayed(new EditorApplication.CallbackFunction(this.PingObjectDelayed), 1f);
         }
     }
 }
예제 #5
0
 public void OnTreeSelectionChanged(int[] selection)
 {
     if (selection.Length != 1)
     {
         return;
     }
     AudioProfilerView.AudioProfilerTreeViewItem node = this.m_TreeView.FindNode(selection[0]) as AudioProfilerView.AudioProfilerTreeViewItem;
     if (node == null)
     {
         return;
     }
     EditorGUIUtility.PingObject(node.info.info.assetInstanceId);
     this.delayedPingObject = node.info.info.objectInstanceId;
     EditorApplication.CallDelayed(new EditorApplication.CallbackFunction(this.PingObjectDelayed), 1f);
 }
예제 #6
0
        static void BenchmarkSnippet(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options)
        {
            var snippetAction = snippet.GetSnippetAction(preExecutePayload, options);

            #if UNITY_2020_1_OR_NEWER
            if (!snippet.ranOnce && options.warmup)
            {
                snippetAction(); // This execution pass should JIT the code first.
                EditorApplication.CallDelayed(() => {
                    var result = ProfilerHelpers.Benchmark(snippetAction, options.count);
                    LogBenchmark(snippet.label, result, options);
                }, 0);
            }
            else
            #endif
            {
                var result = ProfilerHelpers.Benchmark(snippetAction, options.count);
                LogBenchmark(snippet.label, result, options);
            }
        }
        void ConnectionStateGUI()
        {
            if (s_ConnectedTexture == null)
            {
                s_ConnectedTexture    = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml");
                s_ConnectingTexture   = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml");
                s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml");
            }

            Texture2D  iconTexture;
            GUIContent labelContent;
            GUIContent buttonContent;
            HolographicStreamerConnectionState connectionState = PerceptionRemotingPlugin.GetConnectionState();

            switch (connectionState)
            {
            case HolographicStreamerConnectionState.Disconnected:
            default:
                iconTexture   = s_DisconnectedTexture;
                labelContent  = s_ConnectionStateDisconnectedText;
                buttonContent = s_ConnectionButtonConnectText;
                break;

            case HolographicStreamerConnectionState.Connecting:
                iconTexture   = s_ConnectingTexture;
                labelContent  = s_ConnectionStateConnectingText;
                buttonContent = s_ConnectionButtonDisconnectText;
                break;

            case HolographicStreamerConnectionState.Connected:
                iconTexture   = s_ConnectedTexture;
                labelContent  = s_ConnectionStateConnectedText;
                buttonContent = s_ConnectionButtonDisconnectText;
                break;
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(s_ConnectionStatusText, "Button");
            float iconSize = EditorGUIUtility.singleLineHeight;
            Rect  iconRect = GUILayoutUtility.GetRect(iconSize, iconSize, GUILayout.ExpandWidth(false));

            GUI.DrawTexture(iconRect, iconTexture);
            EditorGUILayout.LabelField(labelContent);

            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(m_InPlayMode);
            bool pressed = EditorGUILayout.DropdownButton(buttonContent, FocusType.Passive, EditorStyles.miniButton);

            EditorGUI.EndDisabledGroup();

            if (pressed)
            {
                if (EditorGUIUtility.editingTextField)
                {
                    EditorGUIUtility.editingTextField = false;
                    GUIUtility.keyboardControl        = 0;
                }
                //we delay the call to let the RemoteMachineAddress control commit the value
                EditorApplication.CallDelayed(() =>
                {
                    HandleButtonPress();
                }, 0f);
            }
        }
예제 #8
0
 internal static Action CallDelayed(EditorApplication.CallbackFunction callback, double seconds = 0)
 {
     return(EditorApplication.CallDelayed(callback, seconds));
 }
예제 #9
0
        private void ConnectionStateGUI()
        {
            if (HolographicEmulationWindow.s_ConnectedTexture == null)
            {
                HolographicEmulationWindow.s_ConnectedTexture    = EditorGUIUtility.LoadIconRequired("sv_icon_dot3_sml");
                HolographicEmulationWindow.s_ConnectingTexture   = EditorGUIUtility.LoadIconRequired("sv_icon_dot4_sml");
                HolographicEmulationWindow.s_DisconnectedTexture = EditorGUIUtility.LoadIconRequired("sv_icon_dot6_sml");
            }
            Texture2D  image;
            GUIContent label;
            GUIContent content;

            switch (PerceptionRemotingPlugin.GetConnectionState())
            {
            case HolographicStreamerConnectionState.Disconnected:
IL_5D:
                image   = HolographicEmulationWindow.s_DisconnectedTexture;
                label   = HolographicEmulationWindow.s_ConnectionStateDisconnectedText;
                content = HolographicEmulationWindow.s_ConnectionButtonConnectText;
                goto IL_A2;

            case HolographicStreamerConnectionState.Connecting:
                image   = HolographicEmulationWindow.s_ConnectingTexture;
                label   = HolographicEmulationWindow.s_ConnectionStateConnectingText;
                content = HolographicEmulationWindow.s_ConnectionButtonDisconnectText;
                goto IL_A2;

            case HolographicStreamerConnectionState.Connected:
                image   = HolographicEmulationWindow.s_ConnectedTexture;
                label   = HolographicEmulationWindow.s_ConnectionStateConnectedText;
                content = HolographicEmulationWindow.s_ConnectionButtonDisconnectText;
                goto IL_A2;
            }
            goto IL_5D;
IL_A2:
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            EditorGUILayout.PrefixLabel(HolographicEmulationWindow.s_ConnectionStatusText, "Button");
            float singleLineHeight = EditorGUIUtility.singleLineHeight;
            Rect  rect             = GUILayoutUtility.GetRect(singleLineHeight, singleLineHeight, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });

            GUI.DrawTexture(rect, image);
            EditorGUILayout.LabelField(label, new GUILayoutOption[0]);
            EditorGUILayout.EndHorizontal();
            EditorGUI.BeginDisabledGroup(this.m_InPlayMode);
            bool flag = EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.miniButton, new GUILayoutOption[0]);

            EditorGUI.EndDisabledGroup();
            if (flag)
            {
                if (EditorGUIUtility.editingTextField)
                {
                    EditorGUIUtility.editingTextField = false;
                    GUIUtility.keyboardControl        = 0;
                }
                EditorApplication.CallDelayed(delegate
                {
                    this.HandleButtonPress();
                }, 0f);
            }
        }
예제 #10
0
        static BurstLoader()
        {
            if (BurstCompilerOptions.ForceDisableBurstCompilation)
            {
                UnityEngine.Debug.LogWarning("[com.unity.burst] Burst is disabled entirely from the command line");
                return;
            }

            // This can be setup to get more diagnostics
            var debuggingStr = Environment.GetEnvironmentVariable("UNITY_BURST_DEBUG");

            IsDebugging = debuggingStr != null;
            if (IsDebugging)
            {
                UnityEngine.Debug.LogWarning("[com.unity.burst] Extra debugging is turned on.");
                int debuggingLevel;
                int.TryParse(debuggingStr, out debuggingLevel);
                if (debuggingLevel <= 0)
                {
                    debuggingLevel = 1;
                }
                DebuggingLevel = debuggingLevel;
            }

            // Try to load the runtime through an environment variable
            if (!UnityBurstRuntimePathOverwritten(out var path))
            {
                // Otherwise try to load it from the package itself
                path = Path.GetFullPath("Packages/com.unity.burst/.Runtime");
            }

            RuntimePath = path;

            if (IsDebugging)
            {
                UnityEngine.Debug.LogWarning($"[com.unity.burst] Runtime directory set to {RuntimePath}");
            }

            BurstCompilerService.Initialize(RuntimePath, TryGetOptionsFromMemberDelegate);

            // It's important that this call comes *after* BurstCompilerService.Initialize,
            // otherwise any calls from within EnsureSynchronized to BurstCompilerService,
            // such as BurstCompiler.Disable(), will silently fail.
            BurstEditorOptions.EnsureSynchronized();

            EditorApplication.quitting += OnEditorApplicationQuitting;

#if UNITY_2019_1_OR_NEWER
            CompilationPipeline.compilationStarted += OnCompilationStarted;
#endif

            CompilationPipeline.assemblyCompilationStarted  += OnAssemblyCompilationStarted;
            CompilationPipeline.assemblyCompilationFinished += OnAssemblyCompilationFinished;
            EditorApplication.playModeStateChanged          += EditorApplicationOnPlayModeStateChanged;
            AppDomain.CurrentDomain.DomainUnload            += OnDomainUnload;

            VersionUpdateCheck();

            BurstReflection.EnsureInitialized();

#if !UNITY_2019_3_OR_NEWER
            // Workaround to update the list of assembly folders as soon as possible
            // in order for the JitCompilerService to not fail with AssemblyResolveExceptions.
            // This workaround is only necessary for editors prior to 2019.3 (i.e. 2018.4),
            // because 2019.3+ include a fix on the Unity side.
            try
            {
                var assemblyList    = BurstReflection.AllEditorAssemblies;
                var assemblyFolders = new HashSet <string>();
                foreach (var assembly in assemblyList)
                {
                    try
                    {
                        var fullPath       = Path.GetFullPath(assembly.Location);
                        var assemblyFolder = Path.GetDirectoryName(fullPath);
                        if (!string.IsNullOrEmpty(assemblyFolder))
                        {
                            assemblyFolders.Add(assemblyFolder);
                        }
                    }
                    catch
                    {
                        // ignore
                    }
                }

                // Notify the compiler
                var assemblyFolderList = assemblyFolders.ToList();
                if (IsDebugging)
                {
                    UnityEngine.Debug.Log($"Burst - Change of list of assembly folders:\n{string.Join("\n", assemblyFolderList)}");
                }
                BurstCompiler.UpdateAssemblerFolders(assemblyFolderList);
            }
            catch
            {
                // ignore
            }
#endif

            // Notify the compiler about a domain reload
            if (IsDebugging)
            {
                UnityEngine.Debug.Log("Burst - Domain Reload");
            }

            // Notify the JitCompilerService about a domain reload
            BurstCompiler.DomainReload();

#if UNITY_2020_1_OR_NEWER
            BurstCompiler.OnProgress += OnProgress;
            BurstCompiler.SetProgressCallback();
#endif

#if !BURST_INTERNAL && !UNITY_DOTSPLAYER
            // Make sure that the X86 CSR function pointers are compiled
            Intrinsics.X86.CompileManagedCsrAccessors();
#endif

            // Make sure BurstRuntime is initialized
            BurstRuntime.Initialize();

            // Schedule upfront compilation of all methods in all assemblies,
            // with the goal of having as many methods as possible Burst-compiled
            // by the time the user enters PlayMode.
            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                MaybeTriggerEagerCompilation();
            }

#if UNITY_2020_1_OR_NEWER
            // Can't call Menu.AddMenuItem immediately, presumably because the menu controller isn't initialized yet.
            EditorApplication.CallDelayed(() => CreateDynamicMenuItems());
#endif
        }
예제 #11
0
 static MenuItems()
 {
     EditorApplication.CallDelayed(UpdateMenuItem);
 }