Skip to content

[Bug]: SerializedDictionary Key/Value Visual Offset #284

Description

Description

In some scenerios, when inside a WGroup, the Key field appears to be offset

Image

Steps to Reproduce

namespace Data.Levels
{
    using System.Collections.Generic;
    using System.Threading.Tasks;
    using Environment.Levels;
    using UnityEngine;
    using WallstopStudios.UnityHelpers.Core.Attributes;
    using WallstopStudios.UnityHelpers.Core.DataStructure.Adapters;
    using WallstopStudios.UnityHelpers.Core.Extension;
    using WallstopStudios.UnityHelpers.Core.Helper;
    using WallstopStudios.UnityHelpers.Utils;
#if UNITY_EDITOR
    using UnityEditor;
#endif

    public sealed class LevelDatabase : ScriptableObjectSingleton<LevelDatabase>
    {
        public IReadOnlyDictionary<string, string> ScenesByLevelName => _scenesByLevelName;

        public string InitialLevel => _initialLevel;

        [WGroup("Data")]
        [SerializeField]
        private string _initialLevel = string.Empty;

        [SerializeField]
        private SerializableDictionary<string, string> _scenesByLevelName = new();

#if UNITY_EDITOR
        [WButton("Load All Levels")]
        private async ValueTask LoadAllAsync()
        {
            _scenesByLevelName.Clear();
            List<string> nonLevelScenePaths = new();
            foreach (string scenePath in SceneHelper.GetScenesInBuild())
            {
                if (scenePath.Contains("MainMenu"))
                {
                    continue;
                }
                DeferredDisposalResult<LevelChecker> disposal =
                    await SceneHelper.GetObjectOfTypeInScene<LevelChecker>(scenePath);
                LevelChecker levelChecker = disposal.result;

                try
                {
                    if (levelChecker == null)
                    {
                        this.Log($"Failed to find relevant LevelChecker in scene {scenePath}.");
                        nonLevelScenePaths.Add(scenePath);
                        continue;
                    }

                    LevelConfiguration levelConfiguration = levelChecker.Configuration;
                    if (levelConfiguration == null)
                    {
                        this.LogWarn($"LevelChecker in scene {scenePath} has no configuration.");
                        nonLevelScenePaths.Add(scenePath);
                        continue;
                    }

                    _scenesByLevelName[levelConfiguration.FriendlyName] = scenePath;
                }
                finally
                {
                    await disposal.DisposeAsync();
                }
            }

            foreach (string scenePath in nonLevelScenePaths)
            {
                bool added = _scenesByLevelName.TryAdd(scenePath, scenePath);
                if (added)
                {
                    this.LogWarn(
                        $"Scene {scenePath} is not a level scene, but was added to the database just in case."
                    );
                }
            }

            EditorUtility.SetDirty(this);
        }
#endif
    }
}

Expected Behavior

Really slick, normal looking UI

Actual Behavior

Key field is offset to the right for some reason. Value field is fine.

Severity

Cosmetic (visual/UX issue)

Unity Version

Other

Package Version

3.5.0

Platform

  • Editor
  • Windows
  • macOS
  • Linux
  • iOS
  • Android
  • WebGL
  • Other

Regression

  • Yes, this is a regression (worked in a previous version)

Additional Context

Unity 6000.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions