Tanoda
TransformCopy.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class TransformCopy : MonoBehaviour
6{
7 private Transform copied;
8 private Vector3 savedPos, savedRot;
9 public static TransformCopy instance;
10
11 void Start()
12 {
13 instance = this;
14 }
15
16 public void Copy(Transform value)
17 {
18 copied = value;
19 savedPos = value.position;
20 savedRot = value.eulerAngles;
21 }
22
23 public void Paste(Transform pasteTo)
24 {
25 if (!copied)
26 {
27 pasteTo.position = savedPos;
28 pasteTo.eulerAngles = savedRot;
29 return;
30 }
31
32 pasteTo.position = copied.position;
33 pasteTo.rotation = copied.rotation;
34 if (!Input.GetKey(KeyCode.LeftShift))
35 pasteTo.localScale = copied.localScale;
36 }
37
38}
void Copy(Transform value)
void Paste(Transform pasteTo)
static TransformCopy instance
Definition: TransformCopy.cs:9