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 Farx · Sep 20, 2015 at 07:25 PM · prefabprefabshierarchy

Why do prefabs have redundant transforms?

If I import a mesh (OBJ, FBX, whatever), it gets created as a GameObject with a Mesh Renderer, Transform, etc etc. Now, if I create a prefab from that mesh, by default the prefab consists of a 2-object hierarchy. The root transform, and the mesh as the only child. Both of these objects contain transforms, and presumably I can use the child transform to tweak any scale/rotation issues that might come from the source asset.

However, if all the assets are correct to begin with, and that child transform stays an identity matrix forever, I feel like doubling all the transforms in the scene is a bit of a waste. Is this something to concerned about? Matrix math is not a terribly expensive operation, but what about as scenes get larger? I'm working on a grid-based game, and if a level is a 20x20 grid, that's 400 redundant transforms right there, and that's just the ground tiles. Add in another batch of detail objects for the level, and that number gets larger and larger.

As an alternative, I can tweak the prefab a bit to get rid of the empty parent transform, and just have the mesh as the top-level object. In the image clipped from my hierarchy, I have a crate mesh with an empty parent (the default Unity behavior), vs the crate as its own GameObject. Is there something wrong with going this route, something I might encounter later on that could be disastrous? Or does Unity somehow ignore the redundancy (or it's so trivial a cost I shouldn't worry)?

alt text

prefabexample.png (4.3 kB)
Comment
Add comment · Show 2
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 Cherno · Sep 20, 2015 at 08:22 PM 0
Share

The thing is, you don't create 400 prefabs for a 20x20 grid. You create a two-dimensional array ins$$anonymous$$d of create the mesh procedurally as one (or maybe as multiple chunks, but not with one gameobjecct per grid position).

Back to your original problem: Normally, imported meshes that you drag into the scene and then drag into the project window to create a prefab stay one GameObject, not two. Only skinned models have a hierarchy. I did what you did and just get rid of the parent transform to keep it all flat, it doesn't matter and you are free to do it.

avatar image Farx Cherno · Oct 04, 2015 at 10:31 PM 0
Share

Thanks for the clarification. Not sure why the meshes are imported the way that they are, but I've started to modify them to only have the single transform in their prefabs.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

how to replace multiple game objects with different transform component with same prefab? 1 Answer

Script is reading from prefab instead of instance 1 Answer

Prefab mode doesn't show prefab, still shows old scene. 7 Answers

Creating a weapon database from prefabs 1 Answer

Cant delete clones of prefab 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