GetScenePosRot.cs 972 B

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