Created
July 18, 2023 09:56
-
-
Save karljj1/fda3c7f128a72fb3aeea2984b0619188 to your computer and use it in GitHub Desktop.
Mark LocalizeStringEvent entry as Smart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.Localization; | |
using UnityEngine.Localization.Components; | |
public class MarkSmart | |
{ | |
[MenuItem("CONTEXT/Component/Mark Smart", true)] | |
public static bool MarkEntrySmartValidate(MenuCommand menuCommand) => menuCommand.context is LocalizeStringEvent; | |
[MenuItem("CONTEXT/Component/Mark Smart", false)] | |
public static void MarkEntrySmart(MenuCommand menuCommand) | |
{ | |
var loc = menuCommand.context as LocalizeStringEvent; | |
var collection = LocalizationEditorSettings.GetStringTableCollection(loc.StringReference.TableReference); | |
foreach (var table in collection.StringTables) | |
{ | |
var entry = table.GetEntryFromReference(loc.StringReference.TableEntryReference); | |
entry.IsSmart = true; | |
EditorUtility.SetDirty(table); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment