Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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
7
Question by Melanina · Feb 19, 2013 at 12:40 PM · prefabinstancefieldapplyrevert

How to do not apply fields in prefab

Hi, i have prefab that i have to put many times in my game. This prefab has script with 4 public bools and enum. I change this fields depending on environment. When i changed (for example)collider size in prefab and applied it, i lose all my settings in other instances... I think it is no sense to make prefab for each combination. There is some way to make fields that ignore apply, like a position in transform? Please help me. Sorry for poor English and thanks in advance.

Comment
Add comment · Show 4
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 $$anonymous$$ · Feb 19, 2013 at 12:51 PM 0
Share

Thats how prefabs works, I don't think there is a workaround for this as far as I know, all objects in the scene that inherit from a prefab in your game folder will change automatically if you modify the prefab in your Assets folder.

$$anonymous$$y suggestion would be to not make prefab until you have what you want as base, they should be used only as drag and drop, then modify directly in the scene the other instances by script or in editor.

EDIT: You can alternatively build your own EditorWindow to instantiate the prefab in the scene with certain values, is a bit of work but you won't need to touch your prefab in Assets folder for the scene.

avatar image Melanina · Feb 19, 2013 at 01:03 PM 0
Share

it is disaster :O, if i make prefab and my graphics want change texture in prefab i will have to set my variables from the beginning, on the other hand if i don't create prefab i will have to set texture in each instance ;(

avatar image $$anonymous$$ · Feb 19, 2013 at 01:21 PM 0
Share

Yeah I can feel you, sometime can be redundant, but as I saied do a research for custom inspector and windows, you can create your own editor window where you can instance prefabs or anything else with the settings you want. This is a place to start:

http://docs.unity3d.com/Documentation/Components/gui-ExtendingEditor.html

You can also trying making a script the on Start instantiate the prefabs with the variables you want at the position you want if you don't need a too dynamic system.

Another thing you should check if you have multiple scenes using that prefab the instances changes also there if you modified the one in Assets.

avatar image bobmoff · Jul 04, 2016 at 07:43 AM 0
Share

Thx for posting this question. The answer will help me in every working hour in the future.

1 Reply

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

Answer by Bunny83 · Feb 19, 2013 at 02:54 PM

As long as a value isn't changed it's linked to the prefab value. So when the prefab changes the value will change on all instances which have not modified the value themselfs.

To stop using the prefab value, change the value in the inspector on your instance. This will make the variable to show up in bold text which means it has been changed on this instance. For boolean values you can simply check and uncheck the value.

To revert this you can simply rightclick on the variable in the inspector and select "Revert Value to Prefab". This will link the value back to the prefab value.

edit

Just to make sure you understand how prefabs work.

It's not the prefab which applies something to instances. It'S the instance which links it's values to the prefab. So each instance which hasn't changed any of it's values will read the prefab values. Whenever you change the value on an instance it will become seperated from the prefab value and show up bold.

When you press the "Apply" button on a prefab instance you effectively replace the prefab with the current instance and link all values of this instance to the prefab.

So basically you have full control over any value as long as you understand the dependencies.

You can also separate an instance completely from the prefab by selecting the instance and go to the menu GameObject --> "Break Prefab Instance". This will completely disconnect the instance from the prefab.

Comment
Add comment · Show 3 · 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 Bunny83 · Feb 19, 2013 at 02:57 PM 1
Share

ps: To change a value on the prefab you can simply select the prefab from the project panel and change the prefab directly.

If an object is too deep nested in the prefab you have to temporarily drag the prefab into the scene, do your changes, press "Apply" and delete the instance.

avatar image Melanina · Feb 19, 2013 at 03:35 PM 1
Share

"To revert this you can simply rightclick on the variable in the inspector and select "Revert Value to Prefab". This will link the value back to the prefab value." - hah, this is exactly what i want. I didn't know about this option. It so simple... THX. With version control i can be safe if someone apply all prefab.

avatar image bobmoff · Jul 04, 2016 at 07:42 AM 0
Share

Wow! I don't how I have missed this. Been using Unity for over 2 years now and always struggled with prefabs. Even used extra assets from the store to handle it.

Thank you very much!

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

11 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

Related Questions

Why unity applies prefab position to my reverted gameobject ? 0 Answers

Protect a value from Apply 1 Answer

Changing the Variables of An Instanced Script 2 Answers

How to refer to a collision between clones of the same prefab? C# 1 Answer

Apply Changes to Prefab - Unity 2018 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