Last active
September 5, 2020 04:28
-
-
Save GeorgiyRyaposov/e6d6c609ed8adcc27854ad7da6169347 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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