Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

SharedTableData.SetKeyOrder

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void SetKeyOrder(IReadOnlyList<long> orderedIds);

Parameters

Parameter Description
orderedIds The desired key-id order.

Description

Reorders the keys to match a given sequence of ids.

Keys are arranged in the order their ids appear in orderedIds. Ids that are not listed keep their relative order and follow the listed keys. A null or empty list leaves the order unchanged.

Additional resources: SharedTableData.Entries

<para>Move a key to the front by listing its id first.</para>

using System.Collections.Generic;
using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples { public class SharedTableDataSetKeyOrderExample { public void Run() { var sharedData = ScriptableObject.CreateInstance<SharedTableData>(); long a = sharedData.AddKey("A").Id; long b = sharedData.AddKey("B").Id;

sharedData.SetKeyOrder(new List<long> { b, a }); // B now comes first

Debug.Log(sharedData.Entries[0].Key); // B } } }