Created
September 1, 2022 09:40
-
-
Save karljj1/17938907c2068223e33a07e127a06849 to your computer and use it in GitHub Desktop.
Example of a single column to set/get the Smart String status
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 System; | |
using System.Collections.Generic; | |
using UnityEditor.Localization; | |
using UnityEditor.Localization.Plugins.Google.Columns; | |
using UnityEngine.Localization.Tables; | |
[Serializable] | |
public class GlobalSmartStringColumn : SheetColumn | |
{ | |
public override PushFields PushFields => PushFields.Value; | |
StringTableCollection m_TableCollection; | |
public override void PullBegin(StringTableCollection collection) | |
{ | |
m_TableCollection = collection; | |
} | |
public override void PullCellData(SharedTableData.SharedTableEntry keyEntry, string cellValue, string cellNote) | |
{ | |
// Pick a value for true and false. Lets do 1 is yes and anything else is false | |
bool enableSmartString = cellValue == "1"; | |
// Go through all the entries | |
foreach (var table in m_TableCollection.StringTables) | |
{ | |
var entry = table.GetEntry(keyEntry.Id); | |
if (entry != null) | |
entry.IsSmart = enableSmartString; | |
} | |
} | |
public override void PushBegin(StringTableCollection collection) | |
{ | |
m_TableCollection = collection; | |
} | |
public override void PushCellData(SharedTableData.SharedTableEntry keyEntry, IList<StringTableEntry> tableEntries, out string value, out string note) | |
{ | |
// Use the first table as our source of truth | |
var entry = m_TableCollection.StringTables[0].GetEntry(keyEntry.Id); | |
value = entry != null && entry.IsSmart ? "1" : string.Empty; | |
note = null; | |
} | |
public override void PushHeader(StringTableCollection collection, out string header, out string headerNote) | |
{ | |
header = "Smart String"; | |
headerNote = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment