I know that you can paste a Trasform by right-clicking Transform in the Inspector, pressing Copy Component, right-clicking the Transform of another object and pressing “Paste Component Values”.
So, how do you convert Transform data copied by Inspector to text format and paste it?
Copy x of Position of Transform, paste it on development tool, copy y of Transform’s Position, paste it on the development tool, copy z of Transform’s Position, paste it on the development tool, and apply same for Rotation It takes time and effort to do it to · · · ·.
If possible, I want to copy Transform in Inspector and paste it so that it becomes Vector 3 (Position.x, Position.y, Position.z), Vector 3 (Rotation.xRotation.y, Rotation.z).
What I came up with was converting clipboard data to text format, but is that possible? Is there another way? Anything is okay, so please let me know.
Thank you.
The usage environment is Unity 5.4.0 f 3.
What I came up with was converting clipboard data to text format, but is that possible
Yes it is possible. Here’s how to do it:
Go to player settings > Other settings tab > Configuration section > Api Compatibility Level and change it to .NET 2.0 (Instead of the default .NET 2.0 Subset).
You will need the System.Windows.Form.dll file. Be careful here, there probably are many versions of this dll in your system. The one you will need will be inside your Unity installation folder, under Editor/Data/Mono/lib/mono/2.0. Once you located the file, create a Plugin folder in your project and paste this file. (The plugin folder should be of course, under the Assets folder).
Create an editor folder in your project (if you don’t have one already) and create an editor script like this:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class EditorExtensions
{
[MenuItem(“CONTEXT/Transform/Copy Transform to clipboard”)]
private static void CopyTransformToClipboard()
{
Debug.Log(“Copy position to clipboard”);
Vector3 position = Selection.activeTransform.position;
Vector3 rotation = Selection.activeTransform.rotation.eulerAngles;
string vectorString = String.Format(“Vector3({0},{1},{2})”,position.x.ToString(),position.y.ToString(),position.z.ToString());
vectorString += String.Format(“,Vector3({0},{1},{2})”,rotation.x.ToString(),rotation.y.ToString(),rotation.z.ToString());
System.Windows.Forms.Clipboard.SetText(vectorString);
}
}
This will paste whatever data the transform has into the clipboard so you can do Ctrl + V and paste the data where you want, like a text editor. Hope this helps!