Search Unity

Asset Hunter (Project cleaning tool)

Discussion in 'Assets and Asset Store' started by KristianHJ, Oct 15, 2014.

  1. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Kavika

    Right now its not possible, but I guess it might be a useful feature so I will take a stab at implementing it. You have access to a list of all the USED assets, but that's probably not sufficient for your purpose? (That data is avaliable in the generated '*.ahbuildinfo' files)
     
  2. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Note to all:
    The 'Asset Size' listed in Asset Hunter PRO might be incorrect if your textures are using 'Crunch Compression'. I am aware of the issue and trying to find a way to get more 'trustworthy' assetsize in these cases.
     
  3. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    I just added a way to dump all the files in a given Asset Hunter PRO list to a JSON file in this format:
    I will submit it later today or tomorrow (version 1.2.0), and then Unity might take a couple of days to release the update.

    Code (CSharp):
    1.     {
    2.       "GUID": "bde82299766ff384fa42fa969ebaf550",
    3.       "absPath": "C:/UnityProjects/HeurekaToolsProjects/Assets\\SolarSystem\\RotateUniverse.unity",
    4.       "relativePath": "Assets\\SolarSystem\\RotateUniverse.unity",
    5.       "assetSize": 84,
    6.       "fileSize": 42948,
    7.       "usedInBuild": true,
    8.       "scenesReferencingAsset": [
    9.         "Assets/SolarSystem/RotateUniverse.unity"
    10.       ]
    11.     },
     
  4. MattT5

    MattT5

    Joined:
    Dec 7, 2017
    Posts:
    54
    Hi Kristian,

    First off, thank you for having developed Asset Hunter PRO, it is a great product which solved a problem I had better than I ever could have myself (project bloat, but which files are unused? Start parsing the build log? Ugh)

    Recently I noticed something strange though. A texture that was not in the Unity build report list was still marked as 'used' in AHP. This texture actually did not end up in the build (so the build report was right), so why was AHP marking it? I found out that the texture was referenced in a material, but it was not in one of the visible texture slots in the Inspector. This can happen when you have a Standard Material with textures in its slots, and you change the material shader to a shader with different slot names. The old texture slots are no longer visible in the Inspector, but when you switch the shader back, the old textures reappear. If you open the .mat file, you can see the full list of all textures.

    So, like Unity's own 'Find references in scene' option, AHP finds the texture in the material and therefore marks it as used. However, when Unity creates a build, those textures are ignored and not included in the resulting build. So should AHP see the texture as used? Unused? Used but unused?

    Thanks,
    Matt
     
  5. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hey Matt

    First of all, thanks for the kind words, feels great when people are enjoying the stuff Im creating.
    With regards to the issue you are mentioning I would really like to see an example, If you are able to send the relevant files/project to contact@heurekagames.com that would be of great help.

    My initial guess would be that Unity retains a copy of the original material even though it has been replaced in the instances of that material (https://docs.unity3d.com/ScriptReference/Renderer.GetSharedMaterials.html)
    Maybe its Unity not cleaning up the meta files completely, or maybe its just a small bug in AHP.

    Could you tell me if the material is loaded from the resources folder? That might have something to do with it.

    I appreciate the bugreport, but it would be great if you could send over a testproject that experiences this issue. If that's not possible I will still give a stab at finding the problem though :)
     
    Last edited: Oct 29, 2021
  6. MattT5

    MattT5

    Joined:
    Dec 7, 2017
    Posts:
    54
    Hi Kristian,

    Thanks for the super-quick response! The issue is simpler than you think. I have sent you an example project that shows the issue. For example, this material:

    upload_2019-3-6_14-23-50.png

    has references to other textures. If I change the Shader back to 'standard', you get this:

    upload_2019-3-6_14-24-57.png

    Thanks,
    Mattijs
     
  7. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Thanks Mattijs
    This will help a lot in figuring out what is going on...
     
  8. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Ok so this was a bit trickier to fix than expected.
    The problem comes from the Material file holding references to textures previously assigned.
    The green ID below is the red texture:

    upload_2019-3-7_10-35-47.png

    And that is apparently removed from the build at a later stage, but I have yet to find a way to read that info.
    I could parse it from the buildlog theoretically, but that is potentially a really slow process so I would rather avoid that as I just got Asset Hunter PRO to be pretty fast i think.
    I could also clean old material references (https://forum.unity.com/threads/clear-old-texture-references-from-materials.318769/), but I would also rather not do that since it might be useful information I would be deleting.

    I will add this to the backlog and try to see if the Unity API exposes this information somewhere, but the fix is unfortunately a bit down the line.
     
  9. MattT5

    MattT5

    Joined:
    Dec 7, 2017
    Posts:
    54
    Hi Kristian,

    Yes, that is what I said in my first post. Materials keeping hidden references to textures. And while the issue is quite simple, fixing it might not be. However, I did not say it was a bug, it was more a question of what do you expect in this case?
    On the one hand, technically these textures are used, since they are in the material file, and will show up again when you change to a shader that has the correctly named texture slots. On the other hand, those textures are not in the build, so they are actually unused.
    It kind of depends what you want. I use Asset Hunter PRO to remove assets from the project that do not end up in the build and which I therefore deem to be 'not used'. I expect that any asset in the Unity build report is used, and any other asset is not. So for me the current behaviour is not what I want.
     
  10. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    I agree, Asset Hunter should not show the Red texture as being used, even though the scene indeed references it. I see it as a bug, but not a bug that is easily corrected as it is reliant on Unity's internal functionality. My goal is for Asset Hunter to locate 100% of all unused assets in builds, but until a solution has been found it will have to be 99% instead.

    I think the solution will be to add functionality to Asset Hunter that allows the user to clean excess Material information. I wont run it automatically though, since that information is useful for some users. I cant promise exactly when that feature will be included, but I can promise to start looking into it asap.
     
  11. MetaZhi

    MetaZhi

    Joined:
    Feb 18, 2013
    Posts:
    28
    I'm wondering is it compatiable with 2018.3? It seems the textures and materials of prefabs are deleted.
     
  12. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    I have tried i with 2018.3 although I admittedly use 2018.2 for daily use. It used when I tested it, but I will definately investigate if something is going on. You by no means have to, but if you can send me a testproject that exhibits this behaviour that would be greatly appreciated (heurekagames@gmail.com)
     
  13. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi eblumrich

    I think you might have run into a bug that has to do with removing AH2 before installing AHPRO which leaves behing an unwanted scripting symbol "AH_HAS_OLD_INSTALLED".

    My guess is that you have compile errors right now?
    If thats the case, you can read about the fix in one of my previous comments here: https://forum.unity.com/threads/asset-hunter-project-cleaning-tool.274173/page-5#post-4170880

    Hope this helps - if not, feel free to write again, either here or at contact@heurekagames.com
     
    Last edited: Oct 29, 2021
  14. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Hi.

    I have this problem:

    Assets/Heureka/AssetHunterPRO/Editor/Scripts/AH_VersionUpgrader.cs(67,17): error CS0246: The type or namespace name `AssetHunter' could not be found. Are you missing an assembly reference?

    Assets/Heureka/AssetHunterPRO/Editor/Scripts/AH_VersionUpgrader.cs(68,39): error CS0841: A local variable `oldSettingData' cannot be used before it is declared (in three different lines of code)

    Unity version 2018.3.6f1

    Thanks!!!!
     
  15. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Barritico

    I think you have run into a bug that seems to happens when you have AH2 installed, then installs AHPRO and then Manually deletes AH2. Try the steps i mention in the post just above yours (https://forum.unity.com/threads/asset-hunter-project-cleaning-tool.274173/page-6#post-4369747)

    Pretty sure that will fix your problem.
     
    Barritico likes this.
  16. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
  17. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    A curiosity

    The process takes more than 40 minutes in: "analyzing project" and with the progress bar completed.

    In the task manager, the CPU of the "Unity" task is 0.0-0.2% and the work of the hard disk is 0.0-0.1 MB / s

    It is normal?
    (To wait or interrupt the process)

    Thanks!!!
     
  18. patSilva

    patSilva

    Joined:
    Mar 25, 2019
    Posts:
    27
    Hello Kristian,

    I love your asset, it has helped so much but just a small ask...

    It doesn't seem to know about .cginc files for shaders. Is there a workaround or is there a way for the package to ignore cginc files in the removal process. There are many of them and our Project Manager and Build Manager do not know what these even are, they are basically library files for cg/hlsl. So without them it makes my shaders throw errors. They are constantly using your asset for our projects but are accidentally removing cginc's everytime they do, so this feature would be awesome.

    other than that, this is one of the most reliable assets we have.
     
  19. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Sorry, for some reason I havent been getting notifications from this forum thread. 40min is by no means normal. Please write me at contact@heurekagames.com and we will figure out what is going on
     
    Last edited: Oct 29, 2021
  20. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi PatSilva

    Sorry to you too for the late response, but didn't get notified :|
    You can open settings, select a .cginc file in project view and press the "Ignore file extension" button.
    That should fix your problem
    upload_2019-5-2_22-2-7.png
     
  21. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Version 1.2.2 should be live within a a day or two. It fixes a bug with nested prefabs placed in the resources folder not having all of their dependencies marked as unused.

    If you want to fix this issue without having to wait for 1.2.2 to be live, go to line 225 of AH_SerializedBuildInfo and replace:

    Code (CSharp):
    1. if (assetDict.ContainsKey(aPath))
    2. return;
    With:

    Code (CSharp):
    1. if (assetDict.ContainsKey(aPath))
    2. continue;
    Sorry for the inconvenience
     
  22. kavika

    kavika

    Joined:
    Feb 23, 2017
    Posts:
    4
    I tried it out now. Working great! Thanks :)
     
  23. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Good to hear, thanks for letting me know
     
  24. dylanjameswalch

    dylanjameswalch

    Joined:
    Jun 20, 2018
    Posts:
    12
    Hi there,
    I just purchased your asset and while doing a build after importing, the building process froze at "Copying files to final destination". After force quitting Unity and removing Asset Hunter from my project, the build was successful.

    The build was for a Mac Standalone on a Mac computer. Are you aware of this issue?
     
  25. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi dylanjameswalch

    No I havent heard about that problem before. Could you give a me a bit of info that might help figure out what is going on. e.g. which version of Unity and which version of AHPRO.
    Also do you see the same behaviour in an empty problem, or if you re-imported AHPRO into your project?
    Perhaps you could send me your build log?

    I know its a lot of questions, its just really hard to reproduce a bug that no one else seems to have without a bunch of info
     
  26. eblumrich

    eblumrich

    Joined:
    Nov 12, 2015
    Posts:
    105
    Hi.

    I love the asset, but getting the asset/window to actually work is only successful about 25% of the time.

    Sometimes, the Asset hunter window shows up, right after installing it in a project.

    Other projects require me to re-start unity, before I have the option to use AHP. Still others won't allow me to use AHP, even after I do a complete deletion of the asset from both the project, and my roaming folder.

    In some projects, it just never gives me the option of opening asset hunter, no matter what I do.

    Any idea why this is happening? It is quite frustrating.

    -Thanks!

    I'm using V2018.4.0f1
     
    Last edited: Jun 13, 2019
  27. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Eblumrich

    That sounds really odd. Especially the part about it working sometimes.
    Maybe you can write me at contact@heurekagames.com with details, and we can have the correspondence there?
    I'm especially interested in the situations where it doesn't work, maybe get a copy of the project to check out, or just a log file?
     
    Last edited: Oct 29, 2021
  28. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    181
    On importing Asset Hunter Pro I am getting a load of errors like Assets/Heureka/AssetHunterPRO/Editor/Scripts/AH_VersionUpgrader.cs(67,17): error CS0246: The type or namespace name `AssetHunter' could not be found. Are you missing an assembly reference?

    I am upgrading from a previous version.
     
  29. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Redrag

    Yes, apparently I dropped the ball when I tried to do an auto updater...you are not the first one with this issue. The good thing is its easily fixed. Please read my comment here: https://forum.unity.com/threads/asset-hunter-project-cleaning-tool.274173/page-5#post-4170880
     
  30. AdamKane

    AdamKane

    Joined:
    Dec 3, 2012
    Posts:
    134
    Is there a way to adjust the font colors? For example, the red text on dark grey is a bit hard to see.
     
  31. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Adam

    Right now there is no way for you to do so, but that's not to say I couldn't add it to settings somewhere.
    My guess it you mean the "Clean All" button? Is that a correct assumption?
    upload_2019-6-21_15-58-44.png

    This is a full overview of the AHPRO Windows:
    upload_2019-6-21_16-4-24.png
     
    Last edited: Jun 21, 2019
  32. objectpermanencevr

    objectpermanencevr

    Joined:
    Jul 18, 2018
    Posts:
    1
    I've been having the following issue whenever I try to load a build file (see attached screenshot). AH just freezes up on that error and I have to force quit Unity afterward. Any suggestions on how to fix it?
    I checked and the file is definitely in the folder it's supposed to be in.
     

    Attached Files:

    Last edited: Jun 29, 2019
  33. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    I’m on vacation this week so I can’t test it, but if possible, could you send me a unitypackage with the file in question to contact@heurekagames.com then I will give it a look when I get near a computer again next week
     
    Last edited: Oct 29, 2021
  34. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Heya, I'm looking to upgrade to Pro, though I bought AH2 back in 2015 – obviously outside the free upgrade period. Is there a certain procedure to get Pro with the reduced upgrade fee?
     
  35. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Nick

    You were probably one of my first customers then, really happy to hear you are still using it.
    The reduced upgrade fee is applied automatically by Unity if you are logged in with the user that made the initial purchase.
     
    nickfourtimes likes this.
  36. Adswars

    Adswars

    Joined:
    Jun 28, 2015
    Posts:
    13
    Can i clean up unused textures from particle plugin?

    I try with AH2 it cannot detect those files.
     
  37. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi adswar

    I need a bit more information. Is 'Particle Plugin' a 3rd party asset you have bought from store or?
    Also If a texture is not referenced by anything, it will be seen as unused by AH, so I'm not 100% sure what you mean when you say 'unused texture from particle plugin'.
     
  38. MigrantP

    MigrantP

    Joined:
    Jun 24, 2013
    Posts:
    119
    Hi Kristian,

    I've been using Asset Hunter since 2014, it's a great utility. Does the PRO update support Unity's built in Sprite Atlases? i.e. the ones created by Asset -> Create -> Sprite Atlas. In Asset Hunter 2, the BuildReport incorrectly thinks that the textures used in atlases will end up in the build. In fact only the atlas texture itself goes into the build, not the source textures.

    Cheers!
     
  39. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi MigrantP

    To be completely honest I think that i fact might still be the case although not completely sure. I need to get back to you on this after doing a few tests. If it incorrectly interprets the atlas source images I might have a fix for it....but on the other hand, I'm not sure I would show them as being unused since a lot of people might delete them,. Might be that I have to add it as a setting somewhere
     
  40. MigrantP

    MigrantP

    Joined:
    Jun 24, 2013
    Posts:
    119
    Thanks! I suppose ideally it should show that the textures are being used, but not part of the build. And how much size the atlases are taking up (which can be affected by their own individual texture settings).
     
  41. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Ok so I've had a look, and its actually quite a bit harder to do than I thought. There is no clear cut way of hooking into the buildprocess regarding spriteatlasses. I can definately see how more info on atlasses, and the textures they are comprised off, could be useful. I will add it to my roadmap, but I cant promise it will be in.
     
  42. MigrantP

    MigrantP

    Joined:
    Jun 24, 2013
    Posts:
    119
    Thanks for looking into it!
     
  43. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Its my job :)
     
  44. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    Hi, the documentation states that a build is not necessary and it's possible to press the "Generate button". However, I don't have a generate button. Any tips?

    upload_2019-10-25_14-34-11.png
     
  45. rmon222

    rmon222

    Joined:
    Oct 24, 2018
    Posts:
    77
    Hi, I recently bought Asset Hunter Pro. After the cleaning process I'm getting shader errors like this one:

    Shader error in 'NatureManufacture Shaders/Standard Shaders/Standard Metalic Snow': failed to open source file: 'NM_indirect.cginc' at line 60 (on d3d11)

    Is there a quick fix?

    Thank you
     
  46. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi Leniaal

    Whoops, thats a case of me forgetting to update the documentation. I did indeed have a "generate" button in an earlier version, but I realized that I had to rely on the buildlog to get the best result. Hope this doesn't cause a problem for you. If soo, feel free to write me at contact@heurekagames.com and we will figure something out
     
    Last edited: Oct 29, 2021
  47. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Hi rmon222

    I haven't heard about that problem before. Could it be related to the "false errors" reported in this thread? https://forum.unity.com/threads/all-shaders-fails-to-open-source-file-custom-cginc.523184/

    If not, feel free to write me at contact@heurekagames.com since I might need some repro steps from you
     
    Last edited: Oct 29, 2021
  48. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    Ok, don't worry about it. Was hoping I could do it without a build (Big project, so it takes a while), but I ended up building to get the log so it's ok.

    One more very small remark.

    I read over the CTRL+H keybind so I went to find the following path:
    upload_2019-10-29_17-24-55.png

    But it's actually under
    upload_2019-10-29_17-25-27.png

    Thanks for a great asset :)
     
  49. KristianHJ

    KristianHJ

    Joined:
    May 28, 2010
    Posts:
    350
    Glad to hear it Leenial

    And it seems you found my achilles heel... not updating my documentation as much as i should apparently.
     
  50. Whitebrim

    Whitebrim

    Joined:
    Jul 11, 2017
    Posts:
    17
    1.2.8 version. UI broken. Unity 2017.4.31f1
    assethunter.PNG