Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ayks · Dec 15, 2015 at 08:24 PM · positioncopy

copy/paste position into text editor

Hi,

is it possible to copy paste the 3 position (x,y,z) in one time and paste it in editor like notepad ? I always have to copy paste x, then y, then z :-( I know about copy paste the whole parameters in another object but that is not related.

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Jessespike · Dec 15, 2015 at 09:06 PM

Don't think there's a default way to do that. However, you could write an Editor script:

 using UnityEngine;
 using UnityEditor;
 
 // Adds MenuItems to Unity Editor for copy/paste selected transform's position
 public class CopyPositionEditor : ScriptableObject {
 
     static Vector3 cachedPosition;
 
     [MenuItem ("Edit/Copy Transform Position %#c")]
     static void CopyPosition () {
         if (Selection.activeTransform != null)
         {
             cachedPosition = Selection.activeTransform.position;
             EditorGUIUtility.systemCopyBuffer = cachedPosition.x + ", " +
                                                 cachedPosition.y + ", " + 
                                                 cachedPosition.z;
         }
     }
 
     [MenuItem ("Edit/Paste Transform Position %#v")]
     static void PastePosition () {
         if (Selection.activeTransform != null)
         {
             Undo.RecordObject (Selection.activeTransform, "Paste Transform Position");
             Selection.activeTransform.position = new Vector3(cachedPosition.x, 
                                                              cachedPosition.y, 
                                                              cachedPosition.z);
         }
     }
 
 }
 
Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ayks · Dec 15, 2015 at 09:41 PM 0
Share

Thanks for your answer. First I'm not good enough to script something like this but that looks perfect. I tried this, created a C# (I think it is ? I only js) file butt here are the errors.

Assets/Editor/CopyPosition.cs(14,140): error CS1502: The best overloaded method match for string.String(char*)' has some invalid arguments Assets/Editor/CopyPosition.cs(14,140): error CS1503: Argument #1' cannot convert string' expression to type char*' Assets/Editor/CopyPosition.cs(14,36): error CS0122: `UnityEngine.GUIUtility.systemCopyBuffer' is inaccessible due to its protection level

Don't want to annoy, I'll try to find solutions but not sure to succeed.

avatar image Jessespike ayks · Dec 15, 2015 at 09:47 PM 0
Share

I realized there was an error after posting. Try again, I updated the code.

avatar image ayks Jessespike · Dec 15, 2015 at 09:56 PM 0
Share

Thanks, only

Assets/Editor/CopyPosition.cs(14,36): error CS0122: `UnityEngine.GUIUtility.systemCopyBuffer' is inaccessible due to its protection level

left, I'm looking on internet if I can solve this at least :x

avatar image Jessespike · Dec 15, 2015 at 10:02 PM 0
Share

That's odd, no error here. What version of Unity you running? I tested this with 5.2.2f1

Try this maybe:

  EditorGUIUtility.systemCopyBuffer
avatar image ayks Jessespike · Dec 15, 2015 at 10:06 PM 0
Share

4.6.3f1 for my version. I saw on internet that I have to make the function concerned public but I don't know where it is. I changed by your answer and now no more error ! Just have to find where is the menu now I can succeed in it I guess. Thanks again :v

avatar image ayks ayks · Dec 15, 2015 at 10:34 PM 0
Share

it was at the end of the menu (I think I am a genious now that I found it even if it was clearly indicate in the code) It works perfectly and it will save me time and energy thanks very good answers/code.

avatar image Jessespike · Dec 15, 2015 at 11:15 PM 0
Share

O$$anonymous$$, thanks for verifying. I updated the code to now use EditorGUIUtility. Just in case someone else wants to use this in the future. Can you accept the answers as correct, so the question can be closed. Cheers.

avatar image ayks Jessespike · Dec 15, 2015 at 11:52 PM 0
Share

Fine, it is done, not used to this forum.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Copy Transform 1 Answer

Efficiently mimic movements of GameObject 2 Answers

Problem with Instantiate 2D object to right position C# 1 Answer

Copying movement for period of time 2 Answers

Camera rotation around player while following. 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges