Exemplo n.º 1
0
        /// <summary>
        /// コンパイルを終了した時に呼び出されます
        /// </summary>
        private static void OnFinished(object _)
        {
            var settings = CompileTimeMeasurerSettings.LoadFromEditorPrefs();

            if (!settings.IsEnable)
            {
                return;
            }

            var state = ScriptableSingleton <CompileState> .instance;

            if (!state.IsCompiling)
            {
                return;
            }

            state.StopRecord();

            var startTimeTicks   = state.StartTimeTicks;
            var elapsedTimeTicks = DateTime.Now.Ticks - startTimeTicks;
            var entities         = TimeEntities.LoadFromConfig();
            var entry            = new TimeEntry(startTimeTicks, elapsedTimeTicks);

            entities.Add(entry, settings.MaxCount);

            TimeEntities.SaveToConfig(entities);
        }
Exemplo n.º 2
0
        /// <summary>
        /// GUI を描画する時に呼び出されます
        /// </summary>
        public override void OnGUI(string searchContext)
        {
            var settings = CompileTimeMeasurerSettings.LoadFromEditorPrefs();

            using (var checkScope = new EditorGUI.ChangeCheckScope())
            {
                settings.IsEnable          = EditorGUILayout.Toggle("Enabled", settings.IsEnable);
                settings.MaxCount          = EditorGUILayout.IntField("Max Count", settings.MaxCount);
                settings.DateTimeFormat    = EditorGUILayout.TextField("Date Time Format", settings.DateTimeFormat);
                settings.ElapsedTimeFormat = EditorGUILayout.TextField("Elapsed Time Format", settings.ElapsedTimeFormat);
                settings.ElapsedTimeSuffix = EditorGUILayout.TextField("Elapsed Time Suffix", settings.ElapsedTimeSuffix);

                if (GUILayout.Button("Use Defaults"))
                {
                    settings = new CompileTimeMeasurerSettings();
                    CompileTimeMeasurerSettings.SaveToEditorPrefs(settings);
                }

                if (!checkScope.changed)
                {
                    return;
                }

                CompileTimeMeasurerSettings.SaveToEditorPrefs(settings);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// コンパイルを開始した時に呼び出されます
        /// </summary>
        private static void OnStarted(object _)
        {
            var settings = CompileTimeMeasurerSettings.LoadFromEditorPrefs();

            if (!settings.IsEnable)
            {
                return;
            }

            var state = ScriptableSingleton <CompileState> .instance;

            state.StartRecord(DateTime.Now.Ticks);
        }
Exemplo n.º 4
0
        //================================================================================
        // 関数
        //================================================================================
        /// <summary>
        /// GUI を描画する時に呼び出されます
        /// </summary>
        private void OnGUI()
        {
            if (Event.current.type == EventType.Repaint)
            {
                var backgroundRect = new Rect
                                     (
                    x: 0,
                    y: 0,
                    width: EditorGUIUtility.currentViewWidth,
                    height: EditorGUIUtility.singleLineHeight
                                     );

                EditorStyles.toolbar.Draw
                (
                    position: backgroundRect,
                    isHover: false,
                    isActive: true,
                    on: true,
                    hasKeyboardFocus: false
                );
            }

            var entities = TimeEntities.LoadFromConfig();
            var settings = CompileTimeMeasurerSettings.LoadFromEditorPrefs();

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
                {
                    SettingsService.OpenUserPreferences("Preferences/UniCompileTimeMeasurer");
                }
                if (GUILayout.Button("Clear", EditorStyles.toolbarButton))
                {
                    entities.Clear();
                    TimeEntities.SaveToConfig(entities);
                    Repaint();
                }
            }

            using (var scope = new EditorGUILayout.ScrollViewScope(m_scrollPosition))
            {
                for (var i = entities.Entities.Count - 1; i >= 0; i--)
                {
                    var entry             = entities.Entities[i];
                    var dateTimeFormat    = settings.DateTimeFormat;
                    var elapsedTimeFormat = settings.ElapsedTimeFormat;
                    var elapsedTimeSuffix = settings.ElapsedTimeSuffix;

                    var dateTime = string.IsNullOrWhiteSpace(dateTimeFormat)
                                                        ? entry.DateTime.ToString()
                                                        : entry.DateTime.ToString(dateTimeFormat)
                    ;

                    var elapsedTime = string.IsNullOrWhiteSpace(elapsedTimeFormat)
                                                        ? entry.ElapsedTime.TotalSeconds.ToString()
                                                        : entry.ElapsedTime.ToString(elapsedTimeFormat)
                    ;

                    var label1 = dateTime;
                    var label2 = elapsedTime + elapsedTimeSuffix;

                    EditorGUILayout.LabelField(label1, label2);
                }

                m_scrollPosition = scope.scrollPosition;
            }
        }