ILocalizeTarget.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace I2.Loc
  4. {
  5. public abstract class ILocalizeTarget : ScriptableObject
  6. {
  7. public abstract bool IsValid(Localize cmp);
  8. public abstract void GetFinalTerms( Localize cmp, string Main, string Secondary, out string primaryTerm, out string secondaryTerm);
  9. public abstract void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation);
  10. public abstract bool CanUseSecondaryTerm();
  11. public abstract bool AllowMainTermToBeRTL();
  12. public abstract bool AllowSecondTermToBeRTL();
  13. public abstract eTermType GetPrimaryTermType(Localize cmp);
  14. public abstract eTermType GetSecondaryTermType(Localize cmp);
  15. }
  16. public abstract class LocalizeTarget<T> : ILocalizeTarget where T : Object
  17. {
  18. public T mTarget;
  19. public override bool IsValid(Localize cmp)
  20. {
  21. if (mTarget!=null)
  22. {
  23. var mTargetCmp = mTarget as Component;
  24. if (mTargetCmp != null && mTargetCmp.gameObject != cmp.gameObject)
  25. mTarget = null;
  26. }
  27. if (mTarget==null)
  28. mTarget = cmp.GetComponent<T>();
  29. return mTarget!=null;
  30. }
  31. }
  32. }