Example #1
0
        /// <summary>
        /// GUI を描画する時に呼び出されます
        /// </summary>
        public override void OnGUI(string searchContext)
        {
            var settings = NotNullCheckerSettings.LoadFromEditorPrefs();

            using (var checkScope = new EditorGUI.ChangeCheckScope())
            {
                settings.IsEnable  = EditorGUILayout.Toggle("Enabled", settings.IsEnable);
                settings.LogFormat = EditorGUILayout.TextField("Log Format", settings.LogFormat);

                if (checkScope.changed)
                {
                    NotNullCheckerSettings.SaveToEditorPrefs(settings);
                }

                EditorGUILayout.HelpBox("Log Format で使用できるタグ", MessageType.Info);

                EditorGUILayout.TextArea
                (
                    @"[GameObjectName]
[GameObjectRootPath]
[ComponentName]
[FieldName]"
                );

                if (GUILayout.Button("Use Default"))
                {
                    settings = new NotNullCheckerSettings();
                    NotNullCheckerSettings.SaveToEditorPrefs(settings);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Unity のプレイモードの状態が変化した時に呼び出されます
        /// </summary>
        private static void OnChange(PlayModeStateChange state)
        {
            if (state != PlayModeStateChange.ExitingEditMode)
            {
                return;
            }

            var settings = NotNullCheckerSettings.LoadFromEditorPrefs();

            if (!settings.IsEnable)
            {
                return;
            }

            var list = Validate().ToArray();

            if (list.Length <= 0)
            {
                return;
            }

            var logFormat = settings.LogFormat;

            foreach (var n in list)
            {
                var message = logFormat;
                message = message.Replace("[GameObjectName]", n.GameObjectName);
                message = message.Replace("[GameObjectRootPath]", n.GameObjectRootPath);
                message = message.Replace("[ComponentName]", n.ComponentName);
                message = message.Replace("[FieldName]", n.FieldName);

                Debug.LogError(message, n.Component);
            }

            EditorApplication.isPlaying = false;
        }