CameraAnimationMgr.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using UnityEngine;
  3. public class CameraAnimationMgr : BaseMgr<CameraAnimationMgr>
  4. {
  5. public void Play(string cameraAnimationName)
  6. {
  7. this.ClearCameraAnimationRoot();
  8. GameObject cameraAnimationRoot = this.GetCameraAnimationRoot();
  9. this.m_cameraAnimeCtrl = cameraAnimationRoot.GetComponent<CameraAnimationCtrl>();
  10. this.m_cameraAnimeCtrl.Play(cameraAnimationRoot, cameraAnimationName);
  11. }
  12. public void PlayByPath(string animePrefabPath)
  13. {
  14. this.ClearCameraAnimationRoot();
  15. GameObject cameraAnimationRoot = this.GetCameraAnimationRoot();
  16. this.m_cameraAnimeCtrl = cameraAnimationRoot.GetComponent<CameraAnimationCtrl>();
  17. this.m_cameraAnimeCtrl.PlayByPath(cameraAnimationRoot, animePrefabPath);
  18. }
  19. private void ClearCameraAnimationRoot()
  20. {
  21. GameObject gameObject = GameObject.Find("CameraAnimationRoot");
  22. if (gameObject != null)
  23. {
  24. UnityEngine.Object.Destroy(gameObject);
  25. }
  26. }
  27. private GameObject GetCameraAnimationRoot()
  28. {
  29. GameObject original = Resources.Load("Debug/CameraAnimation/Prefab/CameraAnimationRoot") as GameObject;
  30. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(original);
  31. gameObject.name = "CameraAnimationRoot";
  32. return gameObject;
  33. }
  34. public void Pause()
  35. {
  36. this.m_cameraAnimeCtrl.Pause();
  37. }
  38. public void Resume()
  39. {
  40. this.m_cameraAnimeCtrl.Resume();
  41. }
  42. public void Stop()
  43. {
  44. this.m_cameraAnimeCtrl.Stop();
  45. }
  46. private CameraAnimationCtrl m_cameraAnimeCtrl;
  47. private const string CAMERA_ANIMATION_ROOT_NAME = "CameraAnimationRoot";
  48. private const string CAMERA_ANIMATION_PREFAB_PATH = "Debug/CameraAnimation/Prefab/CameraAnimationRoot";
  49. }