• 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 MountDoomTeam · Sep 22, 2012 at 08:16 PM · prefabselectioncopypaste

Any way to copy and paste GameObjects programatically?

It would be a useful feature. it's impossible to copy objects to a prefab without using an Editor Script so you can't copy an object to a prefab without using a menu option.

Perhaps it's possible to make a "copy to prefab/paste from prefab" function in an Editor Script and access it from a Normal Script?

I dont think it's possible to edit the objects in the Selection of hierarchy, which is held in an array somewhere, and i didnt see any selection copy/paste options in reference.

Is there any way to store GameObjects to a kind of memory and paste them into the game elsewhere?

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
2
Best Answer

Answer by Muuskii · Sep 22, 2012 at 09:03 PM

You mean like a deep copy? What specifically are you trying to accomplish here?

From Object.Instantiate

This is essentially the same as using duplicate command (cmd-d) in Unity and then moving the object to the given location

Comment
Add comment · Show 4 · 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 MountDoomTeam · Sep 22, 2012 at 11:02 PM 0
Share

Thanks $$anonymous$$uuskii! O$$anonymous$$G i didnt realise! i thought you could just instantiate prefabs, although it may be O$$anonymous$$ to instantiate to copy game objects. ok.

I am making some geometry with central symmetries, and as it's procedural, it's best to make the mesh on the fly and then copy the symmetries, and it also makes the code simpler and easier to control via modular programming.

avatar image Muuskii · Sep 22, 2012 at 11:11 PM 0
Share

You're welcome. The idea of instantiating non prefabs is an alien idea to me as well. I don't usually use it ever.

If the answer solves your question, please do mark it as correct.

Thank you.

avatar image MountDoomTeam · Sep 24, 2012 at 06:50 PM 0
Share

hiya, i vote for the answer, it means i mark it as correct? there is another option?

avatar image Muuskii · Sep 24, 2012 at 06:52 PM 0
Share

There should also be a checkmark button underneath where you see the thumbs up and down buttons. Click that to indicate that an answer is correct.

Thank you/

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

11 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

Related Questions

How do I keep a texture different on copied objects? 1 Answer

How to set prefab's script value programatically? 1 Answer

Selecting a newly created empty prefab by an editor script 0 Answers

Tagging a prefab breaks my code? 0 Answers

Why cant I copy anything I have in my Project Tab to the Hierarchy Tab or Scene? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges