Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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
0
Question by jimbobuk · Jan 05, 2010 at 08:26 PM · prefabimporteditor-scriptingmodel

Can I generate prefab instances based on locators inside a 3d model file?

I have quite a complicated spatial setup going on in one of the scenes i'm working on. At the moment I've placed them by hand, but as the number of elements increases and art changes continue occurring its growing frustrating having to do this manually.

I wonder if there is any accepted way of harvesting out certain elements from an imported 3d model and using their position and rotations to create the instances of a given prefab. I guess i'm talking about an editor script which could take the pattern of the names of locators to search the model for, and the prefab to create.

I don't know if actual modelling locators themselves are even imported as they usually don't contain any geometry. At the same time I guess I don't want to waste any time rendering anything that is only present to be a locator for this purpose.

Finally it'd be great if this is at all possible that subsequent imports could have the script update already created instances rather than creating new ones, otherwise the values set for script members on the instances would be lost and i'd have to start again with their setup.

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

2 Replies

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

Answer by Jessy · Jan 06, 2010 at 12:32 AM

I'm not sure if this matches what you need, but I use Blender as a level editor instead of Unity; what I do would work with any 3D app, however. This has gotten kind of complex, and I'm still working on it. (I don't even know what all I've added since I made the forum posts.) I will be putting a cleaned-up version on the Wiki, with complete documentation, once my next game is out, but feel free to check it out.

Working with Unity, and syncing assets, is kind of a freaking pain if you're not using prefabs, if you need your objects to have scripts applied. (Currently, trying to make a copy of a script and attach it to something else seems to be completely undoable, due to bugs, according to me and a few others who have tried.) But if you are using a lot of prefabs, and/or scriptless objects, I believe this solution will work out well for you.

You mention needing to have unique instance variables. Marking something as a "Clone" in this script can accomplish that. However, that takes away from the power of syncing in ways that I haven't even had time to come up with yet. It might be what you're looking for. Maybe run the complete sync once, then "Clone" all the instances, and set up their scripts as desired. Future syncs will keep these values, but update the transforms as dictated by your 3D app. Also, if you make any mesh edits, that will come through as well.

Personally, I have been just syncing my entire level, then running a Menu Item setup script afterwards that sets up all my unique instance variables. Whether that is appropriate for your use, I don't know.

I'm uploading my latest version right now. http://forum.unity3d.com/viewtopic.php?t=32551

Comment
Add comment · Show 1 · 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 jimbobuk · Jan 07, 2010 at 11:08 PM 0
Share

thanks, i'll take a look when i'm next at the keys. Now i'm back at work its harder to find the time (and energy) for home dev!

Glad that i'm not the only one to come across these sort of dilemmas!

avatar image
1

Answer by Stelimar · Jan 05, 2010 at 11:40 PM

This should be possible with an editor script, but I'm not familiar enough with how exactly Unity imports external models to give you a script. However, you should be able to somehow get a list of locators by giving them a specific name, and searching for objects with that name, or something similar.Then just iterate through the list with a for loop, Instantiate() a new object, and copy the position, rotation and scale of the locator.

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 jimbobuk · Jan 06, 2010 at 12:25 AM 0
Share

I guess the question is whether locators even make it into unity to be searchable. I was thinking about this some more and wondered whether empty groups could work which i then place the instantiated prefabs into correctly. Then if the groups are moved in the model the prefabs SHOULD be. Thanks though.

avatar image Stelimar · Jan 06, 2010 at 01:33 AM 0
Share

I'm not sure, but you can always try it and see if it works.

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

No one has followed this question yet.

Related Questions

Generate colliders on a prefab 0 Answers

How do I programmatically assign a GameObject to a prefab? 6 Answers

Changing Settings for Mesh Collider on Model does not update Prefab as expected? 0 Answers

Creating a complex prefab during asset postprocessing 1 Answer

Importing model with animations - Lerpz 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