Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by lovablenachos · May 01, 2015 at 01:23 AM · gameobjectruntimeclone

How to clone a gameobject in runtime (not with instantiating)

Hi,

I'm instantiating a game object and performing a boolean mesh operation on it (effectively making a hole in it) and saving it as a new game object (all in runtime).

How can I clone this new game object in runtime?

Thanks!

Comment
Add comment · Show 4
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 AlwaysSunny · May 01, 2015 at 01:22 AM 0
Share

Perhaps I've misunderstood. "Not with instantiating" seemed like a nonsensical request, but maybe there's something to this I don't know about. What expectation do you have that instantiating doesn't satisfy? Publishing.

avatar image vexe · May 01, 2015 at 02:14 AM 1
Share

@AlwaysSunny 'performant' is not a word ;)

avatar image AlwaysSunny · May 01, 2015 at 04:47 AM 1
Share

@vexe It does an awful good job of sounding like one, though!

What can I say? I'm lexicologically lackadaisical.

avatar image Fappp · May 01, 2015 at 02:38 PM 0
Share
  • Create empty GameObject

  • Add: (mesh renderer, mesh filter)

  • Copy vertices of GameObject 1's mesh filtes to vertices of GameObject 2 meshfilter

  • Build mesh

But that's basically just Instantiating manually. Will be a lot more difficult to texture this properly I guess.

1 Reply

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

Answer by AlwaysSunny · May 01, 2015 at 01:21 AM

You can Instantiate() any game object to which you have a reference; it doesn't need to be a prefab. It typically should be a prefab, but in your case, I suppose not. Consider keeping a hidden "original" version to clone from on which you'll zero-out any transform changes so everything behaves nicely.

Is your boolean script super robust and performant? And did you make it yourself? Gimmie gimmie gimmie! ;)

Comment
Add comment · Show 2 · 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 lovablenachos · May 02, 2015 at 08:09 PM 0
Share

That worked! Never knew you could instantiate non-prefabs, thanks for your help!

avatar image lovablenachos · May 02, 2015 at 11:21 PM 0
Share

@AlwaysSunny I didn't know that! I'll try it later and post the results. The shape is made in runtime so there's no way I can save it as a prefab before starting the game, but I thought you could only instantiate pre-defined prefabs!

The script is called Boolean Ops on the asset store (u3d.as/content/alan-baylis/boolean-ops/80j), it works great normally but I modified the code to work in runtime and it's a bit slow when perfor$$anonymous$$g the operation on 6 pieces of geometry in one method. That's why I needed to copy them ins$$anonymous$$d of cutting the same shape three times (as there are 6,3 of one wall and 3 of another).

Thanks for your help, I'll post results later!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Assign gameObject to a variable at runtime 2 Answers

how to get the prefab path of a game object in Game mode,not Editor mode 1 Answer

grab all game objects with a distance of the object? 2 Answers

Add a gameobject/transform present in a scene to a script on runtime 1 Answer

How do I change the transform of a clone object 1 Answer


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