elmortem / localization

Simple localization system
The Unlicense
1 stars 1 forks source link

When trying to load data, Unity can't find the LocalizeSettings settings file #2

Closed Red-Cat-Fat closed 5 months ago

Red-Cat-Fat commented 5 months ago

I tried loading data from a table into an empty project. When I clicked on the "Load All from Google Sheets" button, an error appeared in the Unity console:

Exception: LocalizationSettings is not found. Localization.LocalizeSettings.MakeInstance () (at Packages/localization/Scripts/LocalizeSettings.cs:52) Localization.Editor.EditorLocalizeSystem.LoadFromGoogleSheet (System.Collections.Generic.List`1[T] localeAssets) (at Packages/localization/Editor/Scripts/EditorLocalizeSystem.cs:78) Localization.Editor.LocalizeSettingsEditor.OnInspectorGUI () (at Packages/localization/Editor/Scripts/LocalizeSettingsEditor.cs:29) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.b__0 () (at <7af1774c9e44458e98ffdab661770f41>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

I suspect that the problem is finding the file via Resources.LoadAll<LocalizeSettings>(""), which restricts the search area within the package folder. I added the package itself via Unity Package Manager, using the git link.

When I replaced the search with Resources.FindObjectsOfTypeAll<LocalizeSettings>() everything worked

Red-Cat-Fat commented 5 months ago

I realized that this problem was related to the issue https://github.com/elmortem/localization/issues/3. So I guess then as part of this problem discuss how to upload files, since LocaleAsset is searched through UnityEditor.AssetDatabase.FindAssets("t:LocaleAsset"); and LocalizeSettings via Resources.LoadAll<LocalizeSettings>(""); It is worth choosing one of the 2 chairs.

elmortem commented 5 months ago

FindObjectsOfTypeAll work only with loaded assets.

UnityEditor.AssetDatabase.FindAssets("t:LocaleAsset") - work only in editor for cache. Resources.LoadAll("") - work at runtime only with Resource folder. Need to add comment about it in readme...

elmortem commented 5 months ago

Fixed at 1.0.4