GetScenePosRot.cs 961 B

12345678910111213141516171819202122232425262728
  1. using Blue;
  2. using UnityEngine;
  3. public class GetScenePosRot : AbstractController
  4. {
  5. public Transform meshTest=>(SceneIOCContainer.Instance.Pull("mesh_test")as GameObject).transform;
  6. public Transform meshTestParent=>(SceneIOCContainer.Instance.Pull("ARSpaceForAll")as GameObject).transform;
  7. private void Awake()
  8. {
  9. this.RegisterEvent<GetScenePosRotEvent>(GetScenePosRotSuccess).UnRegisterWhenGameObjectDestroyed(gameObject);
  10. }
  11. private void GetScenePosRotSuccess(GetScenePosRotEvent e)
  12. {
  13. Vector3 pos = new Vector3(e.PosRot[0].x, e.PosRot[0].y, e.PosRot[0].z);
  14. Vector3 rot = new Vector3(e.PosRot[1].x, e.PosRot[1].y, e.PosRot[1].z);
  15. SetPosRot(pos,rot);
  16. }
  17. private void SetPosRot(Vector3 pos,Vector3 rot)
  18. {
  19. meshTest.transform.parent = meshTestParent;
  20. meshTest.transform.localPosition = pos;
  21. meshTest.transform.localEulerAngles = rot;
  22. }
  23. }