Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEditor;
- public class PositionRotationTransferTool : EditorWindow
- {
- GameObject sourceObject;
- Item targetItem;
- [MenuItem("Tools/PositionRotationTransferTool")]
- public static void ShowWindow()
- {
- GetWindow<PositionRotationTransferTool>("Position Rotation Transfer Tool");
- }
- private void OnGUI()
- {
- sourceObject = (GameObject)EditorGUILayout.ObjectField("Source Object", sourceObject, typeof(GameObject), true);
- targetItem = (Item)EditorGUILayout.ObjectField("Target Item", targetItem, typeof(Item), false);
- if (GUILayout.Button("Transfer Position and Rotation"))
- {
- if (sourceObject != null && targetItem != null)
- {
- Undo.RecordObject(targetItem, "Transfer Position and Rotation");
- targetItem.positionOffset = sourceObject.transform.localPosition;
- targetItem.rotationOffset = sourceObject.transform.localRotation.eulerAngles;
- EditorUtility.SetDirty(targetItem);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement