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 el-RERS · Jan 21, 2015 at 07:25 AM · prefabs

is it possible to apply changes to a prefab without changing the particular property values?

This is a question that is kinda hard to explain but I'll try my best: you see, I'm working on a game with 5 levels (scenes), each one of the have a special prefab whose properties I change in the inspector depending on which level the prefab is in.

It works great but the problem occurs when I decide to make a change to the prefab, no matter how tiny, maybe I just want to change the color of a material... when I press "Apply" all prefabs have this material changed..... BUT obviously the properties I changed in the inspector change as well!! This is a enormous pain in the butt because that means I have to go to each level AGAIN to change the properties in the inspector accordingly!.... my simple question is, is there any possible way to avoid this problem? say, I press the "Apply" button on my prefab, the material changes but the properties are kept as I modified them in the inspector in each scene/level?

geez, that was long... anyway, thanks in advance!

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

Answer by GameVortex · Jan 21, 2015 at 07:42 AM

Yes absolutely. What you describe is actually the default behavior of prefabs. When you apply a prefab, only unmodified properties will be updated on the other instances of that prefab. You can do a quick test and see for yourself.

1: Create an empty GameObject and add a Light component to it.

2: Make it a prefab.

3: Drag the prefab into the scene hierarchy (so you have two instances of it).

4: Change the light intensity value of one of the prefab instances in the scene. You will notice that the value and name is now displayed in bold. This indicates that unity has registered a change in the value.

5: Now change the light intensity of the other prefab instance to something else and hit apply. The value first goes bold and back to normal when applying indicating that the value is synced with the prefab.

6: Selecting the other prefab instance now you should see that the light intensity of that one is still the same changed value (not updated to match the prefab).

So what you describe is as I said the default behavior. It is usually wise though to only apply changes on the original prefab to serve as a template, or else one of the changed prefab instances in your scene you apply instead will be used as the template, with its other changed values.

Note: When you have a custom inspector for a component you have to tell it yourself that a value was changed by using: PrefabUtility.RecordPrefabInstancePropertyModifications. Or else the values will not be registered as changed and they will sync with the prefab.

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 el-RERS · Jan 23, 2015 at 04:08 AM 0
Share

you know what? you are totally right, I was being an idiot and what I was doing was modifying the base prefab ins$$anonymous$$d of each of the instances, I can see now that everytime I change a property of one of the instances it gets bolded which means it's now "protected" from the apply button. Thanks a lot!

avatar image GameVortex · Jan 23, 2015 at 07:24 AM 0
Share

No problem. Happy you got it resolved. =)

avatar image
0

Answer by ronshalev3d · Jul 08, 2019 at 01:21 PM

for those who see this question in unity 2019 today what you can do is to create a Prefab override with the specific changes you made. that creates a version of the prefab but without changing the basics.

unlike the concept of inheritance, where you create a version of a parent template, the override prefabs totally override the base prefabs and changes to the base prefab will be overridden by the changes you made in the version.

it is thus good to build the prefab as a generic template for all stages and then use the override versions as lvl1-enemy lvl2-enemy and so on to instantiate them in masses without too much hassle.

Comment
Add comment · 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

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

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

Related Questions

Trouble with prefabs and activating each other's scripts 1 Answer

Link GUIText to a prefab? 2 Answers

Multiple Doors and Buttons 0 Answers

Accessing a certain prefab and it's children 1 Answer

Why have some of my prefabs and animations files gone blank?? 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