FollowTransform.cs 546 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. namespace Unity.RenderStreaming.Samples
  3. {
  4. class FollowTransform : MonoBehaviour
  5. {
  6. [SerializeField] Transform target;
  7. [SerializeField] Vector3 offset;
  8. [SerializeField] bool followPosition;
  9. [SerializeField] bool followRotation;
  10. private void Update()
  11. {
  12. if (followPosition)
  13. transform.localPosition = target.localPosition + offset;
  14. if(followRotation)
  15. transform.localRotation = target.localRotation;
  16. }
  17. }
  18. }