using System; using UnityEngine; using Object = UnityEngine.Object; namespace I2.Loc { public abstract class ILocalizeTargetDescriptor { public string Name; public int Priority; public abstract bool CanLocalize(Localize cmp); public abstract ILocalizeTarget CreateTarget(Localize cmp); public abstract Type GetTargetType(); } public abstract class LocalizeTargetDesc : ILocalizeTargetDescriptor where T : ILocalizeTarget { public override ILocalizeTarget CreateTarget(Localize cmp) { return ScriptableObject.CreateInstance(); } public override Type GetTargetType() { return typeof(T); } } public class LocalizeTargetDesc_Type : LocalizeTargetDesc where T: Object where G: LocalizeTarget { public override bool CanLocalize(Localize cmp) { return cmp.GetComponent() != null; } public override ILocalizeTarget CreateTarget(Localize cmp) { var target = cmp.GetComponent(); if (target == null) return null; var locTarget = ScriptableObject.CreateInstance(); locTarget.mTarget = target; return locTarget; } } }