/// <summary>
        /// IMGUI Version
        /// </summary>
        /// <param name="position"></param>
        /// <param name="property"></param>
        /// <param name="label"></param>
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var code = property.FindPropertyRelative("m_Code");

            var foldRect = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight);

            property.isExpanded = EditorGUI.Foldout(foldRect, property.isExpanded, label, true);

            EditorGUI.BeginChangeCheck();
            EditorGUI.BeginProperty(foldRect, GUIContent.none, property);
            var localeRect        = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - foldRect.width, foldRect.height);
            var newSelectedLocale = EditorGUI.ObjectField(localeRect, LocalizationEditorSettings.GetLocale(code.stringValue), typeof(Locale), false) as Locale;

            EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                code.stringValue = newSelectedLocale != null ? newSelectedLocale.Identifier.Code : string.Empty;
            }

            if (property.isExpanded)
            {
                EditorGUI.indentLevel++;
                position.height = EditorGUIUtility.singleLineHeight;

                position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(position, code);
                EditorGUI.indentLevel--;
            }
        }
        public static Locale GetLocaleFallback(Locale locale)
        {
            // Use fallback?
            var fallBackLocale = locale.Metadata?.GetMetadata <FallbackLocale>()?.Locale;

            if (fallBackLocale != null)
            {
                return(fallBackLocale);
            }

            var cultureInfo = locale.Identifier.CultureInfo;

            if (cultureInfo == null)
            {
                return(fallBackLocale);
            }

            while (cultureInfo != CultureInfo.InvariantCulture && fallBackLocale == null)
            {
                var fb = LocalizationEditorSettings.GetLocale(new LocaleIdentifier(cultureInfo).Code);
                if (locale != fb)
                {
                    fallBackLocale = fb;
                }
                cultureInfo = cultureInfo.Parent;
            }

            return(fallBackLocale);
        }
        static void CreateItem(ReorderableList list, int index, VisualElement root)
        {
            var element      = list.ListProperty.GetArrayElementAtIndex(index);
            var codeProperty = element.FindPropertyRelative("localeIdentifier.m_Code");
            var locale       = LocalizationEditorSettings.GetLocale(codeProperty.stringValue);
            var label        = locale != null?locale.ToString() : codeProperty.stringValue;

            var group = new ObjectField(label)
            {
                allowSceneObjects = false, objectType = typeof(AddressableAssetGroup)
            };

            group.BindProperty(element.FindPropertyRelative("group"));
            root.Add(group);
        }
        /// <summary>
        /// UI Toolkit version
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var code = property.FindPropertyRelative("m_Code");

            var foldout = new Foldout {
                text = "Identifier"
            };

            foldout.BindProperty(property);

            var localeField = new ObjectField {
                objectType = typeof(Locale), value = LocalizationEditorSettings.GetLocale(code.stringValue)
            };

            localeField.AddToClassList("unity-base-field__input");
            localeField.RegisterCallback <MouseDownEvent>(evt => evt.StopPropagation());
            localeField.RegisterCallback <MouseUpEvent>(evt => evt.StopPropagation());
            localeField.RegisterValueChangedCallback(evt =>
            {
                var locale       = evt.newValue as Locale;
                code.stringValue = locale != null ? locale.Identifier.Code : string.Empty;
                code.serializedObject.ApplyModifiedProperties();
            });
            foldout.hierarchy[0].Add(localeField);
            foldout.hierarchy[0].hierarchy[0].RemoveFromClassList("unity-base-field__input");
            foldout.hierarchy[0].hierarchy[0].AddToClassList("unity-base-field__label");

            var codeField = new TextField {
                label = "Code"
            };

            codeField.RegisterValueChangedCallback(evt =>
            {
                localeField.SetValueWithoutNotify(LocalizationEditorSettings.GetLocale(evt.newValue));
            });
            codeField.BindProperty(code);
            foldout.Add(codeField);

            return(foldout);
        }