Exemple #1
0
        public void OnGUI()
        {
            var debugger = Debugger.instance;

            if (Application.isPlaying)
            {
                EditorGUILayout.BeginHorizontal();

                if (debugger.IsState(Debugger.State.Inactive))
                {
                    if (GUILayout.Button(new GUIContent("Start Recording"), new GUILayoutOption[] { GUILayout.Width(300.0f) }))
                    {
                        debugger.state = Debugger.State.Record;
                    }
                }
                else if (debugger.IsState(Debugger.State.Record))
                {
                    if (GUILayout.Button(new GUIContent("Stop Recording"), new GUILayoutOption[] { GUILayout.Width(300.0f) }))
                    {
                        debugger.state = Debugger.State.Inactive;
                    }
                    if (GUILayout.Button(new GUIContent("Pause Recording"), new GUILayoutOption[] { GUILayout.Width(300.0f) }))
                    {
                        debugger.state = Debugger.State.Rewind;
                    }
                }
                else if (debugger.IsState(Debugger.State.Rewind))
                {
                    if (GUILayout.Button(new GUIContent("Stop Recording"), new GUILayoutOption[] { GUILayout.Width(300.0f) }))
                    {
                        debugger.state = Debugger.State.Inactive;
                    }
                    if (GUILayout.Button(new GUIContent("Resume Recording"), new GUILayoutOption[] { GUILayout.Width(300.0f) }))
                    {
                        debugger.state = Debugger.State.Record;
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginVertical();

            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal();

            debugger.capacityInSeconds =
                EditorGUILayout.FloatField(new GUIContent("Capacity in seconds", "Maximum time recorder will keep."),
                                           debugger.capacityInSeconds, new GUILayoutOption[] { GUILayout.Width(250.0f) });

            GUILayout.Space(80);

            int memorySize = debugger.memorySize;

            EditorGUILayout.LabelField(
                "Memory size", MemorySize.ToString(memorySize));


            m_DebuggerTimeline.SelectedRangeStart = debugger.startTimeInSeconds;
            m_DebuggerTimeline.SelectedRangeEnd   = debugger.endTimeInSeconds;

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            if (!EditorApplication.isPlaying)
            {
                DrawDebuggerTimeline();

                GUILayout.Space(5);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();

                List <FrameDebugProviderInfo> providers = new List <FrameDebugProviderInfo>(Debugger.frameDebugger.ProviderInfos);
                providers.Insert(0, new FrameDebugProviderInfo()
                {
                    displayName      = "All",
                    uniqueIdentifier = -1,
                    provider         = null
                });

                int selectedProviderIdentifier = Debugger.frameDebugger.NumSelected > 0 ? Debugger.frameDebugger.GetSelected(0).providerInfo.uniqueIdentifier : -1;
                int selectedIndex    = providers.FindIndex(provider => provider.uniqueIdentifier == selectedProviderIdentifier);
                int newSelectedIndex = EditorGUILayout.Popup(new GUIContent("Target"), selectedIndex, providers.Select(p => new GUIContent(p.displayName)).ToArray(), new GUILayoutOption[] { GUILayout.Width(400.0f) });
                if (selectedIndex != newSelectedIndex)
                {
                    m_RequestSelectProviderIdentifier = providers[newSelectedIndex].uniqueIdentifier;
                }


                foreach (IFrameDebuggerSelectionProcessor processor in m_SelectionProcessors)
                {
                    processor.DrawInspector();
                }


                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                DrawDebuggerTimeline();

                GUILayout.Space(5);

                foreach (var aggregate in Debugger.registry.aggregates)
                {
                    var gameObject = aggregate.gameObject;

                    var label = string.Empty;

                    foreach (var provider in aggregate.providers)
                    {
                        label += $" {provider.GetType().Name} [{(int)provider.identifier}]";
                    }

                    EditorGUILayout.LabelField(
                        $"{gameObject.name} [{(int)aggregate.identifier}]", label);
                }
            }


            EditorGUILayout.EndVertical();

            if (EditorApplication.isPlaying)
            {
                Repaint();
            }
        }