diff --git a/CHANGELOG.md b/CHANGELOG.md index 667eec9..fe6baa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.2 (2024-10-25) + +* KnotTextKeyReference & KnotAssetReference ToString impl + ## 1.3.0 (2024-09-27) * [breaking change] Asset Store - Moving common parts of code to Knot.Core assembly. Please, delete asset folder before updating diff --git a/Editor/Scripts/Core/EditorUtils.cs b/Editor/Scripts/Core/EditorUtils.cs index d344cbf..a957f59 100644 --- a/Editor/Scripts/Core/EditorUtils.cs +++ b/Editor/Scripts/Core/EditorUtils.cs @@ -22,14 +22,7 @@ internal static class EditorUtils public const string ToolsRootPath = "Tools/" + KnotLocalization.CoreName + "/"; const string EditorStylesResourcesPath = "UI/KnotEditorStyles"; - - - public static bool IsUpmPackage => UpmPackageInfo != null; - - public static PackageInfo UpmPackageInfo => - _upmPackageInfo ?? (_upmPackageInfo = PackageInfo.FindForAssembly(Assembly.GetAssembly(typeof(KnotLocalization)))); - private static PackageInfo _upmPackageInfo; - + public static IReadOnlyDictionary MetadataTypes { get diff --git a/Runtime/Scripts/Key References/KnotAssetKeyReference.cs b/Runtime/Scripts/Key References/KnotAssetKeyReference.cs index 643836b..01f82b4 100644 --- a/Runtime/Scripts/Key References/KnotAssetKeyReference.cs +++ b/Runtime/Scripts/Key References/KnotAssetKeyReference.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Knot.Localization.Data; +using UnityEngine; using Object = UnityEngine.Object; namespace Knot.Localization @@ -26,5 +27,7 @@ protected override void UnRegisterValueUpdatedCallback(string key, Action Application.isPlaying && Value != null ? Value.ToString() : Key; } } \ No newline at end of file diff --git a/Runtime/Scripts/Key References/KnotTextKeyReference.cs b/Runtime/Scripts/Key References/KnotTextKeyReference.cs index eba9e1f..a2d066f 100644 --- a/Runtime/Scripts/Key References/KnotTextKeyReference.cs +++ b/Runtime/Scripts/Key References/KnotTextKeyReference.cs @@ -40,5 +40,7 @@ protected override void UnRegisterValueUpdatedCallback(string key, Action Application.isPlaying? Value : Key; } } \ No newline at end of file diff --git a/Runtime/Scripts/KnotLocalization.cs b/Runtime/Scripts/KnotLocalization.cs index fbfda7e..437c942 100644 --- a/Runtime/Scripts/KnotLocalization.cs +++ b/Runtime/Scripts/KnotLocalization.cs @@ -1,14 +1,9 @@ using System; -using System.Linq; using Knot.Core; using Knot.Localization.Data; using UnityEngine; using Object = UnityEngine.Object; -#if UNITY_EDITOR -using UnityEditor; -#endif - namespace Knot.Localization { /// @@ -18,9 +13,9 @@ public static class KnotLocalization { internal const string CoreName = "KNOT Localization"; internal const string CorePath = Utils.EditorRootPath + "Localization/"; - - public static KnotProjectSettings ProjectSettings => - _projectSettings ?? (_projectSettings = LoadProjectSettings()); + + internal static KnotProjectSettings ProjectSettings => + _projectSettings == null ? _projectSettings = Utils.GetProjectSettings() : _projectSettings; private static KnotProjectSettings _projectSettings; public static IKnotManager Manager => _manager ?? (_manager = ProjectSettings.Manager ?? new KnotManager()); @@ -34,49 +29,6 @@ static void Init() Manager.SetDatabase(ProjectSettings.DefaultDatabase, true); } - - static KnotProjectSettings LoadProjectSettings() - { - KnotProjectSettings settings; - -#if UNITY_EDITOR - var allSettings = - AssetDatabase.FindAssets($"t:{nameof(KnotProjectSettings)}"). - Select(AssetDatabase.GUIDToAssetPath). - Select(AssetDatabase.LoadAssetAtPath).ToArray(); - - if (allSettings.Length == 0) - { - string path = $"Assets/{nameof(KnotProjectSettings)}.asset"; - settings = AssetDatabase.LoadAssetAtPath(path); - - if (settings == null) - settings = PlayerSettings.GetPreloadedAssets().OfType().FirstOrDefault(); - - if (settings == null) - { - var instance = ScriptableObject.CreateInstance(); - AssetDatabase.CreateAsset(instance, path); - AssetDatabase.SaveAssets(); - settings = instance; - - var preloadedAssets = PlayerSettings.GetPreloadedAssets(); - PlayerSettings.SetPreloadedAssets(preloadedAssets.Append(settings).ToArray()); - } - } - else settings = allSettings.First(); -#else - settings = Resources.FindObjectsOfTypeAll().FirstOrDefault(); -#endif - - if (settings == null) - { - settings = KnotProjectSettings.Empty; - Log("Unable to load or create Project Settings. Empty Project Settings will be assigned.", LogType.Warning); - } - return settings; - } - internal static void Log(object message, LogType type, Object context = null) { diff --git a/Samples~/Demo/Localization Assets/KnotTextKeyCollection_demo.asset b/Samples~/Demo/Localization Assets/KnotTextKeyCollection_demo.asset index e95d8e9..6d24755 100644 --- a/Samples~/Demo/Localization Assets/KnotTextKeyCollection_demo.asset +++ b/Samples~/Demo/Localization Assets/KnotTextKeyCollection_demo.asset @@ -31,7 +31,10 @@ MonoBehaviour: _editor: [] - _key: Pages.1.0 _metadata: - _runtime: [] + _runtime: + - rid: 7349065975784275987 + - rid: 7349065975784275988 + - rid: 7349065975784275989 _editor: [] - _key: Pages.1.title _metadata: @@ -102,4 +105,18 @@ MonoBehaviour: _runtime: [] _editor: [] references: - version: 1 + version: 2 + RefIds: + - rid: 7349065975784275987 + type: {class: KnotCultureSpecificDayPostfixMetadata, ns: Knot.Localization.Demo, + asm: Knot.Localization} + data: + _serializationPlaceholder: 0 + - rid: 7349065975784275988 + type: {class: KnotCustomFontMetadata, ns: Knot.Localization.Data, asm: Knot.Localization} + data: + _font: {fileID: 0} + - rid: 7349065975784275989 + type: {class: KnotPrefixMetadata, ns: Knot.Localization.Data, asm: Knot.Localization} + data: + _prefix: 123 diff --git a/package.json b/package.json index 5de9f46..2d486c6 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "com.knot.localization", - "version": "1.3.1", + "version": "1.3.2", "author": "V0odo0", "displayName": "KNOT Localization", "unity": "2021.3", - "description": "Lightweight, scalable and extensible texts & assets localization system for Unity. \n\nWiki: https://github.com/V0odo0/KNOT-Localization/wiki \n\nGitHub: https://github.com/V0odo0/KNOT-Localization \n\nAsset Store: https://assetstore.unity.com/packages/tools/localization/knot-localization-187603 \n\nUnity Forum Thread: https://forum.unity.com/threads/knot-localization.1042891/", + "description": "Lightweight, scalable and extensible texts & assets localization system for Unity. \n\nWiki: https://github.com/V0odo0/KNOT-Localization/wiki \nGitHub: https://github.com/V0odo0/KNOT-Localization \nAsset Store: https://assetstore.unity.com/packages/tools/localization/knot-localization-187603 \nUnity Forum Thread: https://forum.unity.com/threads/knot-localization.1042891/", "dependencies": { - "com.knot.core": "1.0.1" + "com.knot.core": "1.0.4" }, "keywords": [ "localization",