- Home /
Getting at the prefab preview window
I am currently working on a Level Editor for my game, a Editor extension not runtime.
Basically its a row of buttons, each corresponding to a prefab they will instantiate in the scene. Right now i have to manually create a icon for each button, and this isn't very optimal as i have quite a few items. Also, many of them may change during the development of the game. Which makes me have to update the icon.
The ideal solution would be for the icon to be generated automatically, a small version of whats get shown in the preview window when the prefab is selected.
Is there any way of doing this? Either by somehow rendering the preview to a image and then use that. Or by rendering the preview window on the actual button.
Answer by Mattivc · Jan 24, 2013 at 11:25 AM
This problem has now been solved thanks to the new AssetPreview class in 4.x
AssetPreview.GetAssetPreview(Object);
Will return a image of the given gameObject.
works gr8!, but if i need this on runtime? thanks for you quick answer :)
This seems like what I need, but do I have to create/instantiate each prefab I have to get a preview of it? I have 10 prefabs and I want to get the Preview of each. Do I need to create an instance of the prefab to get the preview? I'm assu$$anonymous$$g I do, because it asks for the Object, not the Name.
Answer by AngryAnt · Jun 30, 2012 at 09:50 AM
I don't think we have that level of access to the automatic preview. What you could do though is write an asset post processor which, on import of these specific prefabs:
Populates your list of buttons
Instantiates the prefab
Frames a camera on it by getting the combined renderer bounds
Render the camera to a texture
Once you have the basics in place you can play around with attaching a lighting setup to your camera, adding a bit of padding, framing the object and maybe placing it at a slight angle.
Answer by startassets · Mar 12, 2017 at 07:46 PM
@Mattivc I've just finished my own preview asset, maybe it will be useful for you: https://forum.unity3d.com/threads/powerful-preview.460157/
Your answer
Follow this Question
Related Questions
Why do my prefabs not have an Asset Preview? 1 Answer
How to get Project view's preview icon size? 0 Answers
Change angle of camera in prefab preview 4 Answers
Change angle of camera in prefab preview 1 Answer
Custom Thumbnails for Prefabs 0 Answers