• 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
2
Question by VivienS · Dec 10, 2010 at 10:42 AM · prefabmaterialprefabsmaterials

Prefabs losing Material connections after re-opening scenes. Bug?

Hello there!

I keep encountering a certain problem:

I am creating small animated prefabs of collections of about 10-15 game objects for re-use in scenes. These prefabs usually contain ~10secs of keyframed meshes, particles, skinned meshes, material-animations, etc (nothing out of the ordinary).

Now, sometimes those prefabs just happen to lose some of their material connections.

It usually happens after I re-open the scenes where the prefabs are instantiated. They then show up partially pink (the missing-material-pink) and I have to re-assign the materials by hand and hit apply. It happens without warning (theres no sign that the prefabs or their instances are damaged while I am working on them). I wasn't able to isolate the problem further than that (will post updates when I find out more!).

Any idea what could be the problem here? Some known issues with the animation editor or something that I overlooked?

Oh, and I am using Unity Pro 3.10f4 on Win-7 x64.

Thanks!


UPDATE:

With the suggestion of Mike, I watched the problem further. Though I'm still not able to recreate it step by step, I'm pretty sure it has something to do with the material instances.

Usually when a material that is shared by different objects in a scene is animated on single objects, Unity creates an instance of this material the moment the animation starts playing. Also, when the animation stops again or when you stop animating in the animation editor the object is re-assigned its original material and everything is fine.

Now, I noticed that sometimes during the process of animation, I seem to end up with the instanced materials left on the object after stopping animation. It goes hand in hand with left-over changes in other animated properties like transform. When I accidentally apply those changes to the prefab, it is not able to find this material instance, and hence appears with the pink missing material on scene-reload or on instancing.

Anyone able to confirm this or am I misinterpreting things?

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 nowhereman · Dec 18, 2010 at 12:47 AM 0
Share

I'm having the same problem... the materials in my project keep randomly going missing after re-opening the the scene. it only happens about 1% of the time, but it's enough that it's starting to get annoying...

avatar image ptoinson · Dec 23, 2010 at 04:05 AM 0
Share
  • as I'm having the same issue. Nothing less than annoying.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Mike 3 · Dec 10, 2010 at 02:08 PM

If you're manipulating the renderer.material property of a prefab, it'll cause the prefab to create an instance of the material and assign that as the actual material - the issue is that when you reload the scene, that instance will be long gone

Try animating the renderer.sharedMaterial property instead - that one is the one you should always be using when manipulating things at editor time

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 VivienS · Dec 13, 2010 at 03:41 PM 0
Share

Thanks for the reply! I am always animating the material property in the animation editor. Right now f.i. it has a name like "$$anonymous$$y$$anonymous$$esh (Instance) ($$anonymous$$aterial)". That sounds like the render.material property you mentioned (?) - and it behaves like that too: There are ~20 objects that share this very same material & each one has a unique material animation (right now f.i. they fade in, one after the other). But I did it like that since the beginning and it works in ~90% of cases. In the ohters, i simply re-assign the material and it works too. I'll keep an eye on the instance materials!!

avatar image
0

Answer by VivienS · Jan 25, 2011 at 07:08 PM

Ok, now I managed to replicate at least one way this error appears:

  1. create a random mesh (game object with mesh renderer component, i.e. sphere) with a random custom material
  2. parent it to a new game object and add an animation component and an animation clip to this parent
  3. convert the two into a prefab
  4. add a random material animation to the object (i just animated an alpha-fade on an opaque object, so there's no visible change)
  5. make sure that the animation editor is still in record mode and hit Ctrl+D on the object to duplicate it (loses the prefab connection, but never mind that for now). The new game object now has only an instance of the material assigned
  6. hit apply on the prefab, reopen the scene and voilinstance material lost!

alt text

There have to be other ways too though. I'm pretty sure that I also encountered it without the above steps. So I'm not sure how helpful this is in your cases. I guess I'll now try to avoid this action as well as check my prefabs for left-over material instances before I close the scenes.

If you come across other ways to create this effect, I'd be great if you could post them here as well so we know what to look out for!

Thank you, vv

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

Answer by BluEye · Aug 25, 2012 at 03:01 PM

Hello,

This seems to be what is going on with mine except mine became pink when I switched to the new Macbook Pro Retina Display. Everything...and I mean everything went pink. It does not matter if they share the same materials or not.

To go through hundreds beyond hundreds and fix them seems well very time consuming...as does spending 100+ hours redoing the scene from scratch.

Anyone have any advice. I'm thinking somehow the connection of the Materials go lost in the migration...humm

I brought the materials folder and so forth over to the Project. Even when I do take one of the materials and drag it onto one of the objects...it goes white instead of taking on the created material.

and to add more to this mayhem, the scripts did not migrate over, or they did and I've no idea where they all went.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

New prefab system problem 1 Answer

How can I make that everyTime I change the texture of material, it won't change texture of every Instantiated Object that has that material 2 Answers

Assign different materials to a range of same prefab? 1 Answer

How do I use the same material on 2 meshes without distortion? 2 Answers

Display GUI menu after last object left the screen 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges