MegaGlobeLink.cs 614 B

123456789101112131415161718192021222324252627282930313233343536
  1. 
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. public class MegaGlobeLink : MonoBehaviour
  5. {
  6. public Transform target;
  7. MegaGlobe globe;
  8. public float angle = 0.0f;
  9. void Update()
  10. {
  11. if ( target )
  12. {
  13. Vector3 scale = target.localScale;
  14. if ( globe == null )
  15. {
  16. globe = GetComponent<MegaGlobe>();
  17. }
  18. if ( globe )
  19. {
  20. globe.radius = scale.x / 2.0f;
  21. Vector3 lpos = Vector3.zero;
  22. lpos.x = Mathf.Sin(angle) * globe.radius;
  23. lpos.z = Mathf.Cos(angle) * globe.radius;
  24. Vector3 pos = target.position + lpos; //target.TransformPoint(lpos);
  25. transform.position = pos;
  26. }
  27. }
  28. }
  29. }