Jump to content

Instancing - Model shared between different prefabs?


Hgawmphdmph
 Share

Go to solution Solved by Rick,

Recommended Posts


I have what may be some kind of instancing issue.

I have a model created in Blender and imported to Leadwerks. I opened a new empty map, dragged in the model, attached a lua script, and saved the result as a prefab. I then opened another new empty map, dragged in the model again, attached a different lua script and saved the result as a second prefab.

The model has no material. Both of the scripts create their own new material and attach it to their associated entity. Each then make changes to it's material - one uses a buffer to write and draw graphics to its associated material, the other switches the textures of its material to produce animation.

If I add one instance of each prefab to any empty level, at runtime the same output appears on both objects. The script attached to the last prefab dragged in, draws  to both objects. (To be clear, these are instances of two DIFFERENT prefabs.)

If I remove the script whose output is showing from it's associated entity, the script attached to the other object draws to BOTH objects.

If I remove the object whose script is showing everywhere, the other one starts showing what would be expected from its own attached script.

If I drag in further instances of the model, the current dominant script output is drawn to those also.

If I drag new instances of one of the prefabs into the scene, the last one dominates and its associated script affects ALL objects with this model, whether standalone model instances or instances of either prefab.

It's as if a model is always instanced and shared, between different prefabs and even between different standalone versions of the model.

Is this the case? Can anyone help with what on Earth is going on?

Thanks all.

Link to comment
Share on other sites

  • Solution

Yes, I believe if the same model is dragged into the editor, it in instanced which means they share certain aspects, material being one of them. In code I believe the Copy() method you can specify if you want the material to be shared or not, but as far as I recall in the editor the only way was to make a totally different model (not prefab but model). I did at one point suggest to give us a way to specify when dragging models into the scene if they should be instanced or copied without material sharing. The reason for the way it is would be it's less resources to share that information.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...