Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Arithan · Feb 16, 2013 at 03:27 AM · prefabperformance

Best Way to Create Pile of Gold Coins

I currently have a single gold coin modeled, imported into Unity, and made it a prefab. Now I also want to make a pile of gold coins with the same coin so I can make something like a treasure room. What would be the best way to do this performance-wise?

In Blender, I duplicated that single coin many times and spread them out to make a gold pile. Then rendered an image from the top view to use as a texture. I then modeled a low poly mesh in the shape of a gold pile and put the texture on it. The problem is that it looks very flat when done this way.

I was wondering if it would impact performance if I made a gold pile from the coin in Unity by duplicating the prefab multiple times and then turning the finished gold pile into another prefab. Once a prefab is loaded, does it have to load it again for each instance of it?

I did some searches but most of the results were related to gold farming.

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
0

Answer by Chronos-L · Feb 16, 2013 at 07:10 AM

In Unity, there is a built-in script ( CombineChildren.cs + MeshCombineUtility.cs ) for combining mesh in the children object ( Assets -> Import Package -> Scripts ).

The following is the comment from the script:

 /*
 Attach this script as a parent to some game objects. The script will then combine the meshes at startup.
 This is useful as a performance optimization since it is faster to render one big mesh than many small meshes. See the docs on graphics performance optimization for more info.
 
 Different materials will cause multiple meshes to be created, thus it is useful to share as many textures/material as you can.
 */

So, by parenting all your coins to an empty object and attach CombineChildren.cs to the empty object. A new mesh containing all the coins' meshes will be generated at runtime; and according the comment "it is faster to render one big mesh".

P/S: If all the pile of gold coins are going to look the same anyway (or you are going to have just 3-5 different looking piles), you can just join them in Blender as one object before exporting it to Unity (so you would not need to combine them in runtime).

Comment
Add comment · Show 5 · 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 Arithan · Feb 16, 2013 at 07:21 AM 0
Share

Thanks, but I think combining them into one mesh would make it too high poly. The coin pile texture I made in Blender is from spreading out a bunch of the same coin (80 Tris each). In the end, all coins combined is 25,200 Tris, which is way too many. If Unity only loads the same prefab once no matter how many times I use it, I think that would be a better solution, but I'm not sure if it does load only once.

avatar image Chronos-L · Feb 16, 2013 at 01:13 PM 0
Share

I am not exactly sure how the Unity works with prefab. Perhaps this article will be able to help to figure out the answer to your question, and it might help you improve the performance of your game as well.

avatar image Arithan · Feb 16, 2013 at 07:48 PM 0
Share

Thanks for the link. I learned a thing or two about performance, but it still didn't really answer my question. However, reading about draw calls, I guess I can just experiment and see if making the gold coin pile with multiples of the same prefab increases the draw calls.

avatar image Chronos-L · Feb 17, 2013 at 04:07 AM 0
Share

Good luck.

avatar image Arithan · Feb 17, 2013 at 08:23 AM 0
Share

After experimenting, the number of draw calls stay the same if I reuse the same prefab multiple times, but the Tris/Verts count goes up, obviously. I guess to get the best of both worlds, I can do what I did and create a low poly mesh to put the coin pile texture on, and then put a few 3D coins sticking out so it doesn't look so flat.

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

10 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

Related Questions

Not a question - just some performance metrics for rendering from Unity scripts 0 Answers

What Techniques are used for multi-level games and keeping APK size to minimum? 2 Answers

Are prefabs better for performance? 1 Answer

Does enabling/disabling Scripts have a high performance cost? 1 Answer

All project as child of one gameObject is a good idea? 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