Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Thumbnail Generator - EditorTool

Discussion in 'Assets and Asset Store' started by Twilice, Nov 23, 2020.

  1. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20

    Thumbnail Generator Tool is a global editor tool with the purpose of very easily take HD screenshots in any scene or in the prefabStage with simple drag&drop features for extra assets to include.

    Noteable features are:
    • Plug&Play, it's a global Editor Tool, no need for any gameobject or custom scenes.
    • Drag & drop any scene to use as a backgroundScene.
    • Drag & drop any material to use for postProcess (includes material+example for easy Frame creation)
    • Drag & drop any postProcessVolume
    • support Legacy, URP and HDRP pipelines
    • Quick selection meny dropdown to create thumbnails for multiple objects at once
    • Use custom resolution for those ULTRA HD or those super small images.

    I wanted the tool to be easy to use while also supporting advanced features that a user could want that makes their workflow easier.




    So far I've gotten sales here and there, but no reviews or communication. So I am not sure if users like or dislike the tool or in what direction the tools focus should be. Most of the current design has mostly been driven by a lot of self reflection.
    Even if you do not own this asset or if you do own it! It would be great if you had some feedback on what kind of features you would want to see or if there has been any kind of issues.
     
  2. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I met a problem when using this plugin. I am using the URP and 2019.4. The prefab thumbnail result is a gray image.
     
  3. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hello, thank you for writing!

    I have noticed an issue when you have a custom dpi/pixel scaling in your OS. Which can cause the camera to show the wrong location which in turn can cause a grey image because the model is not in focus.

    If the preview is not centered it is likely this issue. And I am currently working on a fix for this and will publish a new version as soon as possible.

    If you have no pixel scaling and the preview is centered it could also be that you are trying to snap a screenshot of the overlay canvas which has a different rendering path in Unity and is not rendered on the built in cameras and will also result in a grey area if you have nothing more than an overlay canvas. I have added a custom experimental setting to temporarelly allow the tool to change canvas positioning to world space while snappning screenshot to include overlay canvas.

    If it is something else apart from the above 2 causes, please get back to me and include a screenshot of the editor after klicking generate thumbnail.
     
  4. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555

    I upload a screenshot to show this problem. There have two problems.
    1. It seems the position of this shell is different between the preview and the thumbnail show in memory. I think this is the problem what you say.
    2. The image write by EncodeToPNG seems a totally gray texture. But the texture in memory is correct. Maybe there has something wrong with the 'EncodeToPNG' in 'ThumbnailGenerator.SaveThumbnail'?

    BTW, I add an Apply after the CopyTexture:
    Code (CSharp):
    1.  
    2. Graphics.CopyTexture(RenderTexture.active, newTexture);
    3. newTexture.Apply();
    4.  
    And the texture in memory becomes gray too.
     

    Attached Files:

    Last edited: Dec 10, 2020
  5. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Ah, thank you for the screenshot! In previous patch I goofed and didn't notice the generation wasn't saved to HD. I was thinking that I made such a small patch so I didn't double check the saved files... Very stupid of my me, and I apologize.

    In the last patch I renamed some variables and forgot to swap the true/false usage...
    I plan to release a fix for your issue nr1 and nr2 in the same patch. If you do not wish to wait for asset store to update for issue nr2 you can swap which code is in the if/else cases.

    The following is correct:
    Code (CSharp):
    1.             // read from renderTexture into Texture2D
    2.             if (isPreview)
    3.             {
    4.                 Graphics.CopyTexture(RenderTexture.active, newTexture);
    5.             }
    6.             else
    7.             {
    8.                 newTexture.ReadPixels(new Rect(0, 0, thumbnailWidth, thumbnailHeight), 0, 0, false);
    9.                 newTexture.Apply();
    10.             }

    EDIT:
    I desided to upload a hotfix for non-saved .png's as it is a very important issue to be resolved. I uploaded without a new versionnumber to asset store since it was a very unintended change. Hopefully it will be approved asap.

    As for issue 1 I am having some trouble finding a way to get the the scaling property in preferences via script. Still working on it. If anyone knows I would be glad happy to know!


    EDIT2:
    For anyone reading this looking for the same setting. I found the setting in EditorGUIUtility.pixelsPerPoint
    Update v1.2d (1.2.3) which fixes both issues is now uploaded to asset store and will hopefully be avaliable for download as soon as it passes review.
     
    Last edited: Dec 10, 2020
  6. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    Thanks for the fix! Now it is correct to make a thumbnail.
    Now I met a lighting problem, it seems the environmental light is not correct. The thumbnail and preview are always darker than the scene view.
    I think I can use a custom BackgroundScene to fix this, but I hope without it, the thumbnail lighting can be the seem in the scene view.
     
  7. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Great to hear that those issues were resolved with the patch!

    Sadly the lightning issue is another beast. If you use Scene Lightning on you should get the same lightning in preview as without.

    But when Scene Lightning is toggled off so the special SceneView Lightning is used I have had some issues with finding how to fetch and use that special light. Instead Scene Lightning is used, and if no SceneLight avaliable two custom lightsources is used similar to the lightning used in Unitys PreviewRenderUtility.

    This is an issue I want to resolve. And the custom light is just a workarround to not getting completely dark scenes. The best solution would be if I can find a good way of extracting that special SceneView light, the next best solution might be to add more manual user control for dynamically created light. But currently no big changes planned unless I get a eureka moment (would gladly appreciate user suggestions!).

    If it looks like it is the actual SceneLightning is not used but something different then it could be a bug which I should resolve as soon as possible. If you build lightning in your scene and try the difference when toggling sceneView lightning on/off with tool active/not active is there a large difference?

    sceneview_lightning.jpg
     
  8. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I have an immature idea. Can we just get the m_SceneTargetTexture from the SceneView class out by using reflection. And clip and blit it?
     
  9. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    I might have found something even better. SceneView has a SetupCustomSceneLighting and CleanupCustomSceneLighting. Working with them in the normal SceneView yields expected results so far in 2019.4 legacy-RP. Some minor issues that I want fixed for prefabStage. And then testing for newer version and URP/HDRP.

    So looks like a better fix is possible! But will probably require quite some testing before going live since it's highly possible that functions are renamed/removed/altered functionality when calling the internal api with reflection by "magic string".

    EDIT:
    Forgot to note that the above fix is live.
     
    Last edited: Dec 22, 2020
  10. olas72

    olas72

    Joined:
    Jul 9, 2012
    Posts:
    15
    upload_2021-5-29_14-32-25.png upload_2021-5-29_14-32-53.png \

    When I go to do thumbnails, the image looks like it is clipping out some of the model, like the camera clipping plane is set to close.


    Some Feature Suggestions:
    - Ability to save and load multiple camera positions
    - Light rigs attached to the thumbnail generator that are tunable and loadable
    - Select Prefab from list and load and render them in world
    - Batch render all prefabs in a folder
     
    Last edited: May 29, 2021
  11. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hey!

    If you are using "quick generate" via dropdown menu the near clipping will be set to default 0.3. If you are using the tool window it will copy the values in the current scene camera.
    upload_2021-5-29_21-6-54.png

    If you need to change clipping plane in quick generate you can send me a another message and I can add it as soon as possible.

    If you turn on the camerasettinglight it will use the lights in the current scene. Or if you specify a backgroundscene it will use the lights from that scene (so you can for example have a "lightingscene".)

    upload_2021-5-29_21-11-44.png

    If none of the above actions are working as expected, please get back to me and specify Unity version, renderpipeline and if you had any custom materials.
     
  12. olas72

    olas72

    Joined:
    Jul 9, 2012
    Posts:
    15
    Thanks for the quick response.

    I tried changing the clipping plane in the gizmos. Didn't seem to make a difference.

    If I move the camera closer or further away in the thumbnail editor, the amount of clipping on the model stays the same.

    I'm using Unity 2021.1.3f
    Using the standard renderpipeline

    Standard material with nothing special on it

    upload_2021-5-29_16-37-46.png
     
  13. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    When I lock a bit closer on the images, it might be something with the renderorder. But since you are using the standard material that shouldn't be an issue.

    Would you be ok with sending me the project or the model in a private message so I can take a look?
     
  14. olas72

    olas72

    Joined:
    Jul 9, 2012
    Posts:
    15
    For sure. Let me try and set something up
     
  15. olas72

    olas72

    Joined:
    Jul 9, 2012
    Posts:
    15
    Hmmm, I separated them out so I could send you the file and it works ok in a isolated file. Any thoughts on what I can look at?

    upload_2021-5-29_21-33-11.png
     
  16. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hm, I would doublecheck if some of the materials has been set to Transparent instead of Opaque.

    Another thing could be if there is a replacementshader set on the camera that changes the z-testing / depth buffer.


    EDIT:
    When exactly does the issue happen? Is it as soon as you start the tool and even in the preview, or is it when you click generate thumbnail? Or are you using the dropdown menu called quick generate thumbnail.
    The images are created slightly different from another depending on what option you are using.
     
  17. olas72

    olas72

    Joined:
    Jul 9, 2012
    Posts:
    15
    Yea, happens right from the moment I turn on the tool, in preview as well
     
  18. Weblox

    Weblox

    Joined:
    Apr 11, 2016
    Posts:
    277
    Hi @Twilice - I looked at the Prefab example video and I wonder if this support a list of multiple Prefabs as well to be batched (screenshotted) ?
     
  19. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hello!

    Depending on what kind of feature you need it might suit, but high risk that it's not exactly what you want. The tool is very limited in multi prefab regards, there is no option for dynamic/automatic updates/generation.

    But you can manually select and generate screenshots of multiple prefabs at the same time. (it will the use settings setup in "quick generation settings")



     
    Weblox likes this.
  20. Weblox

    Weblox

    Joined:
    Apr 11, 2016
    Posts:
    277
    Thanx 4 the quick reply. Yes - very nice. That should fit my needs. I will put it on my wishlist... :p
     
  21. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    429
    hi, @Twilice does the thumbnail generator can be run in some sort of batch mode? Imagine the situation when I would like to generate thumbnails for 100 prefabs at once. Is there some API exposed?

    In addition to the previous similar replies: I would like to integrate tool such as this into my editor tools and not have to select prefabs in project view (for example because I got the references to the prefabs stored elsewhere already)
     
    Last edited: Jan 3, 2022
  22. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Yes and no (check above screenshots), the batch supported only includes selected objects in the editor, with limited options compared to using the tool in the scene. You can however set global default settings and quickly generate lots of thumbnail using that setting.

    If you want to use the API it will probably not solve what you want to do, since the tool was designed around being able to take any kind of screen via the sceneViews with custom settings such as postProcess or default backgroundScenes. The API takes the cameras rather than the gameobjects as input. (the quick generate function is very different and I could possibly expand that one to suit your needs if you have an idea of how you want to use it.)


    Some kind of improved batching is the most sought out feature (or at least make quick create more obvious feature), but so far I don't know a good non-breaking way of doing it.
     
  23. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    Did you find the SetupCustomSceneLighting and CleanupCustomSceneLighting make the unity crash silently in some case?
     
  24. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Oh, that sounds bad. Do you remember in which cases? And which version. I've never had it happen myself. But I also mostly work in studio projects which don't feature my personal tools, so it's possible I've missed some bugs that exist in newer versions.
     
  25. Dolmek

    Dolmek

    Joined:
    Jun 28, 2015
    Posts:
    12
    Hello I'm using Unity 2020.3.42f1, I get no error messages but I there is no picture in the global toolbar, and can't create any of the Thumbnail Generator. Am I missing something?

    upload_2023-1-31_21-8-44.png
     
  26. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    If you press the "custom tool" it should show up.
    upload_2023-1-31_21-15-31.png

    Otherwise the prefab Thumbnail Generator dropdown is supposed to be used on prefabs as a quick "goto".
     
    Dolmek likes this.
  27. Dolmek

    Dolmek

    Joined:
    Jun 28, 2015
    Posts:
    12
    You were right, thank you! I never used custom toolbar so I didn't knew that.
     
  28. jasonrbrock

    jasonrbrock

    Joined:
    May 22, 2019
    Posts:
    15
    Hi @Twilice, followed your youtube vid but am unable to get transparent background to work .. I notice in your vid the saved thumbnail format's 'RGBA DXT5' which is different to the 'RGB DXT1' format that's being generated on my system. Am I doing something incorrect?
    (MAC OSX Monterey, Unity 2021.3, URP)
     
  29. jasonrbrock

    jasonrbrock

    Joined:
    May 22, 2019
    Posts:
    15
    Fired up an SRP project .. transparent background works out of the box.
    I see URP's commented out in ThumbnailGenerator.cs ..... doesn't work?
     
  30. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hm, transparency is supposed to work fine for URP. For HDRP it should also work but you have to manually enable a setting in Unity https://docs.unity3d.com/Packages/c...high-definition@10.2/manual/Alpha-Output.html

    The commented out code is experimental code related to postProcessing. Sadly I don't remember exactly what the issues were, but it shouldn't relate to transparency.


    Are you using the tool by "right klicking" a prefab and choosing quick create or by opening the tool window and taking a screenshot? They use 2 different techniques. Both should work though.

    upload_2023-2-5_18-33-47.png


    My best current guess is that you computer/unity does not support RGBA32, but that also sounds weird to me so not so sure it will work. But if you want to you can try and change the textureFormat to another format in the source file and test if it changes anything.
     
  31. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    It could also be related to import settings being changed in newer versions of UnityI'll have to double check with another version and get back to you later in the week.

    But if I change Alpha Source or Alpha Is Transparency then my image will also be compressed to DXT1.
    upload_2023-2-5_18-40-44.png
     
  32. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    I have now confirmed that it is also happening to me that transparency is not in 2021.3.15f using URP on windows.

    But that's good in a way, that means when I find the issue I can test the solution myself and post an update.

    I think the update will also include a fix to the dropdown not opening the Thumbnail Generator window if you don't klick on a prefab. I have noticed it's a bit less obvious, if one has not used custom editor tools, where to open the tool if you just want to casually open it in the scene.

    Hopefully I can have a fix ready at the of the weekend.

    EDIT:
    Okay I have found a few more bugs in 2021.3.15f when changing between scene and prefabs it snaps back to the scene. I didn't notice these bugs when I tested in Unity 2022.1 so I didn't think they would be this kind of bugs present in "in between" versions. I will try and roll out a larger fix to also address this if I find the cause.
     
    Last edited: Feb 8, 2023
  33. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    upload_2023-2-8_19-25-47.png
    I found the issue! So new URP templates include already turned on postprocessing by default which overrides transparency. So there is no transparency in the scene photograped scene. Hence why the transparency disappears. If this is unwanted you can turn off post processing in the settings.

    Maybe I should include a warning and a quick override button if I detect that no transparency is going to be written. Maybe it would be possible to reapply transparency somehow, but I'm afraid it might ruin the post process effect.
     
    jasonrbrock likes this.
  34. PixelNAUTS_Alex

    PixelNAUTS_Alex

    Joined:
    Sep 14, 2012
    Posts:
    56
    Any chance we can get Post-processing and Transparency in URP?
     
  35. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    You can use both together in URP, as long as you don't use a post processing effect which writes a 1 to all alpha channel. You can also use a PostProcessProfile or material.

    Hm, it seems it's a wanted feature. It's kind of a hacky workaround since it's Unitys effect that overrides the alpha. But possibly I could do a custom option to take 1 screenshot without post process - only to store the alpha. Then take a new with post processing and again overwrite the overridden alpha with the "original" one. Depending on which post processing effect though, this might look even worse if it's a displacement effect.

    I'm not going to say yes, but a big maybe if I get some time over. Do you need it for something special?
     
  36. Wolvman92

    Wolvman92

    Joined:
    Oct 31, 2021
    Posts:
    12
    Hi,

    I'm not sure if this is a Script Inspector issue or a Thumbnail Generator issue but if I'm using the Script Inspector asset from the Unity store to write my code it brings up Thumbnail Generator every time I hit the U key. I'm not having this issue with any other assets so I'm trying to figure out why this would happen. It looks like I can use the U key in other inspector fields but not Script Inspector.

    Any ideas how I can fix this?
     
  37. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hello!

    Which Script Inspector asset are you using?

    There is nothing in my tool which uses the U Key. Without knowing which other asset you are using it's very hard to know. But my wild guess is that they are possibly using U Key to open the first Editor Tool that exist in a list. Which happen to be Thumbnail Generator.

    To my knowledge the U key is not used for anything in Unity, what would you expect to happen? Knowing this can help me help you figure it out^^
     
  38. Wolvman92

    Wolvman92

    Joined:
    Oct 31, 2021
    Posts:
    12
    Thanks for the help. I think I've got it traced back to Ultimate Editor Enhanced actually. I deleted that asset and it seems to be working fine now.
     
    Last edited: Jul 12, 2023
  39. Twilice

    Twilice

    Joined:
    Oct 28, 2016
    Posts:
    20