LocalizeTarget.cs 551 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using UnityEngine;
  3. namespace I2.Loc
  4. {
  5. public abstract class LocalizeTarget<T> : ILocalizeTarget where T : UnityEngine.Object
  6. {
  7. public override bool IsValid(Localize cmp)
  8. {
  9. if (this.mTarget != null)
  10. {
  11. Component component = this.mTarget as Component;
  12. if (component != null && component.gameObject != cmp.gameObject)
  13. {
  14. this.mTarget = (T)((object)null);
  15. }
  16. }
  17. if (this.mTarget == null)
  18. {
  19. this.mTarget = cmp.GetComponent<T>();
  20. }
  21. return this.mTarget != null;
  22. }
  23. public T mTarget;
  24. }
  25. }