Prefab Plugin: Work in Progress (Updated)

Update 1

image

If you are familiar with Unreal Engine 4 or Unity you probably know bother use a prefab system and changing one object will change all of them. That’s obviously a time saver for scripters and modelers, especially when you may have 25 to 100+ of the same thing you want to change.

I’m not sure how much this will help you but I’m trying to get close to that prefab system as possible. You may not like how it is working currently though.

Currently it just relies on the Source copy to have a PrimaryPart, it doesn’t have to be at the bottom of the model I just chose to do that. All the copies must also have a primary part, or at least a “base” part so the script knows how to orientate the updated copy of the model.

The models being updated have the name of the Source model.

If you would use this let me know and what you would like it to do/be flexible with so it suits your workflow. All models be updated have to be in “Reference” and all source models have to be in “Source” currently. This will change once later to only rely on updated References through the new Tag system.

Update 2

Now a Tag based system so you no longer have to worry about grouped models or individual duplicates.

Summary


image

Moved to ReplicatedStorage.
image

Now a button for Refresh instead of a UI.
image

Still going to work on hotkeys such as maybe Ctrl + R for refresh, requiring you to select what prefabs you want to refresh or else it will attempt to refresh all prefabs at once.

The great thing now is you no longer need to have a name based system, it will update all tagged objects with the source prefabs tags.

Ex: WoodenBox can contain tags: “Shore Box, Facility Box” and all objects containing those tags will get refreshed.

Still working on make it not delete the original object and instead just replace it’s children.

Update 3

  • Supports multiple copies through a folder.

  • Moving or deleting a prefab will prompt a message if you want to delete all references.

  • Renaming the prefab will update all prefab tags of all instances related to it to match the new name.

13 Likes

I’d definitely be interested in something like this, but it’d be great to see a few improvements:

Prefab Storage:

I would prefer prefab sources to exist in ReplicatedStorage. The Workspace is already cluttered, and prefab sources living here makes them harder to access.

Prefab Variance:

It would be cool to have multiple sources for the same prefab. For instance, I could make 3 variants of trees, and whenever I click the prefab update button, the single “Tree” prefabs across the map randomly select one of the three trees

Prefab Reference:

Tags are great. This will allow me to do stuff like “Box by the docks” and group appropriately rather than relying on name/structure.

Prefab Interface:

I can’t tell what you have on your UI, but I’d prefer if the plugin had no GUI and just plugin buttons, or at least an option for that. A GUI would feel bloated for something like this.

Programming API:

It would be useful to provide some sort of programming API for in-game use. For instance, I might have “themes” for player houses, and want to switch out all "MedievalChair"s for "ScifiChair"s.

A few concerns with this would be object state. For instance, when I replace MedievalDoor with SciFi door, do I replace an open MedievalDoor with a closed SciFi door, or do I somehow magically detect that the medieval door is swung open, and trigger another API which slides the SciFi door open? And what happens if I replace a MedievalChest with a SciFiChest? Do I lose all my items in the chest?

This may be resolvable by preserving the model instance. For instance, instead of destroying the model and replacing it, clear its children and place the new children inside the old model. The process would look something like:

  • Unset tag “Preset_MedevialDoor”
  • Clear children of model
  • Add children of SciFiDoor to model
  • Set tag “Preset_SciFiDoor”

Since the model is preserved, I can use my own tags like ChestId=12 to retain the chest’s identity, and since the model is never removed I don’t have to reset my references in my scripts. I can also handle state changes with tags like DoorState=Open, so when GetInstanceAddedSignal is fired with Presfab_SciFiDoor, I can check for an existing DoorState tag and set the new door to open/closed.

3 Likes

I was experimenting, the UI itself was just a R “Refresh” button. I could make this a plugin with no UI whatsoever and let it simply rely on just shortcut keys but I also don’t want to overlap other keybinds and sometimes controls are visually better to handle with minimal UI.

I agree with every other point made though but the reason I did the model source in workspace was because that’s the only way I could edit it. Of course I expect as much it would be far better with it being in storage since you wont always go back to it. This was done in literally an hour or so. Ill work on the tag version tomorrow.

1 Like

Updated progress. @EchoReaper

1 Like

If you need ideas for how to implement this, you could allow for either folders or models to be parented to Prefabs. If it’s a folder, the prefab selects one of its child models at random. If it’s a model, that’s the prefab. Prefabs are named after their folder rather than individual models, so I could have a prefab folder named Crate and its contents CrateRusty and CrateNew. Adding a model to the folder automatically adds the tag Prefab_FolderName to the model.

Yeah, I’ll be adding that soon, I’m still wondering about how to handle updating the references. Might as well just stick to requiring a “PrimaryPart” for the sake of orientation and positioning cause you never know if you want to expand the size of the model or not.

I’ll evetually make a tutorial on this plugin when it’s in a more “production” releasable state.

1 Like

Can definitely use this…

1 Like

Going to make it ask if you would like to delete all references if the Prefab object is removed.

image

1 Like

So what are you using for Empty objects for telling the plugin what objects go where?

Currently if the object it’s trying to update does not have a primary part then it will throw a warning for that object and not use it. The main reason for that is it needs a reliable guide for how to orientate the change so cases like update a light pole won’t put it into the ground when you try to make it taller.

I plan to release a tutorial that goes over all the buttons and quirks once I publish it.