Skip to content

Instantly share code, notes, and snippets.

@GeorgiyRyaposov
Last active September 5, 2020 04:28
Show Gist options
  • Save GeorgiyRyaposov/e6d6c609ed8adcc27854ad7da6169347 to your computer and use it in GitHub Desktop.
Save GeorgiyRyaposov/e6d6c609ed8adcc27854ad7da6169347 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections.Generic;
using System;
using System.Linq;
namespace Assets.Scripts.Domain.Localization
{
[CreateAssetMenu(fileName = "Localization", menuName = "Data/Localization")]
public class LocalizationItem : ScriptableObject
{
public SystemLanguage Language;
public List<Term> Terms;
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(LocalizationItem))]
public class LocalizationEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
if (GUILayout.Button("Add"))
{
var translation = (LocalizationItem)target;
translation.Terms.Add(new Term());
}
if (GUILayout.Button("Sort"))
{
var translation = (LocalizationItem)target;
translation.Terms = translation.Terms.OrderBy(o => o.Key).ToList();
}
DrawDefaultInspector();
}
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment