GameObjectExtensionMethods.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Copyright(c) Live2D Inc. All rights reserved.
  3. *
  4. * Use of this source code is governed by the Live2D Open Software license
  5. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
  6. */
  7. using UnityEngine;
  8. namespace Live2D.Cubism.Core
  9. {
  10. /// <summary>
  11. /// Extends <see cref="GameObject"/>s.
  12. /// </summary>
  13. public static class GameObjectExtensionMethods
  14. {
  15. /// <summary>
  16. /// Finds a <see cref="CubismModel"/> relative to a <see cref="GameObject"/>.
  17. /// </summary>
  18. /// <param name="self"><see langword="this"/>.</param>
  19. /// <param name="includeParents">Condition for including parents in search.</param>
  20. /// <returns>The relative <see cref="CubismModel"/> if found; <see langword="null"/> otherwise.</returns>
  21. public static CubismModel FindCubismModel(this GameObject self, bool includeParents = false)
  22. {
  23. // Validate arguments.
  24. if (self == null)
  25. {
  26. return null;
  27. }
  28. return self.transform.FindCubismModel(includeParents);
  29. }
  30. }
  31. }