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 Tatanan · Apr 09, 2015 at 01:19 PM · prefab

Vars on prefabs

I am building my own prefabs. When I initiate a prefab on my hierarchy, if I modify a var and after that I click on "Apply", all other instances of this prefab are changed too.

Is there any way to define a var whose value is not saved on the prefab even if I click on "Apply"?

Basically I would like to edit my prefab but also having "free vars".

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

Answer by DiegoSLTS · Apr 09, 2015 at 01:56 PM

You can't define a variable to not be updated, that's against the purpose of a prefab, anything that you haven't changed manually in the prefab is linked to the prefab values.

Anything that's not linked to the prefab value will be displayed in bold, you can "unlink" a field by changing it manually, even if you write the same value the field already has, or drag the same reference. Once the field is displayed in bold, changes on the prefab won't affect it.

Note that if you "apply" on the instance those values would be used as defaults and will be linked again to the prefab (the bold letters will turn to normal), so be carefull when applying changes. I always create an instance, make a change, apply, and delete the instance, so the instances that I actually want remain unlinked.

Comment
Add comment · Show 6 · 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 Tatanan · Apr 09, 2015 at 02:24 PM 0
Share

mmm, that's a pity. Let's say a have a weapon prefab and 10 instances with 10 difference values (strength for example). I want to edit the prefab and all the instance (resistance for example).

You are saying I can't do it, right?, ie, if I edit the prefab I'll lose my 10 strength vars, right?

avatar image Tatanan · Apr 09, 2015 at 02:57 PM 0
Share

One more thing @DiegoSLTS: There are some vars that always unlinked in prefabs: the Transform vars and others like the sprite name. I am looking for that.

I mean, the x, y and z positions can be modified freely. However, a var from a component cannot. Is it right?

Thank you.

avatar image DiegoSLTS · Apr 09, 2015 at 04:25 PM 1
Share

That's because when you drop a prefab into the scene Unity changes the transform values. Look at the inspector, the fields are in bold.

If you right click on them and select "Return Value to Prefab" the fields are linked again.

To test this, create a prefab with a Cube, then add 2 instances of the prefab on the scene, one with the transform linked, and the other unlinked. Then changed the x position on the prefab (selecting the prefab in the project window) and only the instance that is linked will move.

About the strength example, if you manually edited the strength field of each instance (i.e., the field name is in bold), when you apply changes to a prefab, the instances will not be changed on that field.

avatar image Tatanan · Apr 10, 2015 at 10:40 AM 0
Share

@DiegoSLTS, that's exactly what I was looking for. $$anonymous$$aybe I just didn't make the question clear enough.

You are clai$$anonymous$$g that I can have vars synchronised with the prefab and some other "free", right?

Just to clarify:

  1. If I want a var to be syncronised again (ie, be updated when the prefab is updated), I have to click on Revert, right?

  2. If I have 2 vars manually edited (bold) and I want only one of them to be synchronised again, it's possible, since "Revert" will synchronised both, right?

avatar image DiegoSLTS · Apr 10, 2015 at 02:39 PM 1
Share

@Tatanan When you select "Revert Value to Prefab" on a field it just unlinks that field on that instance (you don't have that option on the prefab itself).

I'm not sure if this answers your second question, I'm not sure if you meant "possible" or "impossible", but no, reverting a field in one instance of the prefab won't synchronize all the fields, only the one you tell Unity to revert. Note that fields like "Position" on the Transform component can be unlinked as a whole (right click on the "Position" word) or you can unlink individual values (right click over the "X", "Y" or "Z" label next to each field).

Show more comments

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

18 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Previewing mesh before instantiating 1 Answer

Shadows (pro) disappear on Unity restart 0 Answers

Tower defense target update 0 Answers

Problems with detecting tags 1 Answer

Swipe to place order in ShopScrollList (prefabs, object pooling, instantiating) 0 Answers


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