SFX_FxObjectInstancer.cs 1005 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. // ReSharper disable once CheckNamespace
  3. namespace QFX.SFX
  4. {
  5. public static class SFX_FxObjectInstancer
  6. {
  7. public static void InstantiateFx(SFX_FxObject sfxFxObject, Vector3 targetPosition, Vector3 targetRotation)
  8. {
  9. var go = Object.Instantiate(sfxFxObject.Fx);
  10. go.transform.position = targetPosition;
  11. if (sfxFxObject.FxRotation == SFX_FxRotationType.Normal)
  12. {
  13. go.transform.rotation = Quaternion.FromToRotation(go.transform.up, targetRotation) *
  14. go.transform.rotation;
  15. }
  16. else if (sfxFxObject.FxRotation == SFX_FxRotationType.Default)
  17. {
  18. go.transform.rotation = Quaternion.identity;
  19. }
  20. else if (sfxFxObject.FxRotation == SFX_FxRotationType.LookAtEmitter)
  21. {
  22. go.transform.LookAt(targetRotation);
  23. }
  24. go.SetActive(true);
  25. }
  26. }
  27. }