docs.unity3d.com
    Show / Hide Table of Contents

    Class SheetColumn

    Represents a single Google sheet column with its value and note field.

    Inheritance
    Object
    SheetColumn
    KeyColumn
    KeyMetadataColumn<TMetadata>
    LocaleColumn
    LocaleMetadataColumn<TMetadata>
    Namespace: UnityEditor.Localization.Plugins.Google.Columns
    Syntax
    [Serializable]
    public abstract class SheetColumn
    Examples

    This is an example of how to synchronize the IsSmart property. Any value in the column causes all values to be marked as smart; leaving the field empty indicates they should not be smart.

    [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)
    {
        bool enableSmartString = !string.IsNullOrEmpty(cellValue);
    
        // 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 ? "x" : string.Empty;
        note = null;
    }
    
    public override void PushHeader(StringTableCollection collection, out string header, out string headerNote)
    {
        header = "Smart String";
        headerNote = null;
    }
    }

    Properties

    Column

    The Id of the column.

    Declaration
    public string Column { get; set; }
    Property Value
    Type Description
    String

    ColumnIndex

    Column as an index where 0 = 'A', 1 = 'B' etc.

    Declaration
    public int ColumnIndex { get; set; }
    Property Value
    Type Description
    Int32

    PushFields

    Controls which cell fields to synchronize.

    Declaration
    public abstract PushFields PushFields { get; }
    Property Value
    Type Description
    PushFields

    Methods

    ColumnNameToIndex(String)

    Convert a column name to its id value. E.G 'A' = 0, 'B' = 1, 'AA' = 26, 'AB' = 27

    Declaration
    public static int ColumnNameToIndex(string name)
    Parameters
    Type Name Description
    String name

    The name of the column, case insensitive.

    Returns
    Type Description
    Int32

    The column index or 0.

    Exceptions
    Type Condition
    ArgumentException

    IndexToColumnName(Int32)

    Converts a column id value into its name. Column ids start at 0. E.G 0 = 'A', 1 = 'B', 26 = 'AA', 27 = 'AB'

    Declaration
    public static string IndexToColumnName(int index)
    Parameters
    Type Name Description
    Int32 index

    Id of the column starting at 0('A').

    Returns
    Type Description
    String

    The column name or null.

    PullBegin(StringTableCollection)

    Called when starting a pull to allow a column to initialize itself.

    Declaration
    public abstract void PullBegin(StringTableCollection collection)
    Parameters
    Type Name Description
    StringTableCollection collection

    The collection to update from the Google Sheet.

    PullCellData(SharedTableData.SharedTableEntry, String, String)

    Called to update the StringTableCollection using the provided cell data.

    Declaration
    public abstract void PullCellData(SharedTableData.SharedTableEntry keyEntry, string cellValue, string cellNote)
    Parameters
    Type Name Description
    SharedTableData.SharedTableEntry keyEntry

    The entry being updated for this cell.

    String cellValue

    The cell value or null if PushFields does not contain the flag Value.

    String cellNote

    The cell note or null if PushFields does not contain the flag Note.

    PullEnd()

    Called after all calls to PullCellData(SharedTableData.SharedTableEntry, String, String) to provide an opurtunity to deinitialize, cleanup etc.

    Declaration
    public virtual void PullEnd()

    PushBegin(StringTableCollection)

    Called when starting a push to allow a column to initialize itself.

    Declaration
    public abstract void PushBegin(StringTableCollection collection)
    Parameters
    Type Name Description
    StringTableCollection collection

    The collection to push to a Google Sheet.

    PushCellData(SharedTableData.SharedTableEntry, IList<StringTableEntry>, out String, out String)

    Extracts the data that should populate the columns cell for the row associated with the Key.

    Declaration
    public abstract void PushCellData(SharedTableData.SharedTableEntry keyEntry, IList<StringTableEntry> tableEntries, out string value, out string note)
    Parameters
    Type Name Description
    SharedTableData.SharedTableEntry keyEntry

    The Key that represents the row in the spreadsheet.

    IList<StringTableEntry> tableEntries

    The StringTableEntry for the current SharedTableData.SharedTableEntry. The order of the tables will match the source StringTableCollection, If a table does not contain data for the current key then a null entry will be used.

    String value

    The value to be used for the cell. This can be null if PushFields is Note or the cell should be empty.

    String note

    The value to be used for the cell note. This can be null if PushFields is Value or if there should not be a note for this cell.

    PushEnd()

    Called after all calls to PushCellData(SharedTableData.SharedTableEntry, IList<StringTableEntry>, out String, out String) to provide an opurtunity to deinitialize, cleanup etc.

    Declaration
    public virtual void PushEnd()

    PushHeader(StringTableCollection, out String, out String)

    Sets the column title and optional note. These values are always set regardless of the value of PushFields.

    Declaration
    public abstract void PushHeader(StringTableCollection collection, out string header, out string headerNote)
    Parameters
    Type Name Description
    StringTableCollection collection
    String header

    The title to use for the column header.

    String headerNote

    Optional note that can be added to the header.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023