Search Unity

Bug PSB asset inspector window is breaking

Discussion in 'Editor & General Support' started by deetorz, Sep 9, 2022.

  1. deetorz

    deetorz

    Joined:
    Sep 3, 2020
    Posts:
    5
    I am working on a 2D project and everything was fine until I accidentally clicked the "Platform Settings" option in the inspector of my psb asset. The option opened and then the inspector breaks. I cannot click on anything in the inspector. Unity still works, but the inspector on this asset in particular won't work. In addition, the console is flooded with the same error:

    Code (CSharp):
    1. NullReferenceException: Max Size: SerializedProperty is null
    2. UnityEditor.EditorGUI.BeginPropertyInternal (UnityEngine.Rect totalPosition, UnityEngine.GUIContent label, UnityEditor.SerializedProperty property) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
    3. UnityEditor.EditorGUI.BeginProperty (UnityEngine.Rect totalPosition, UnityEngine.GUIContent label, UnityEditor.SerializedProperty property) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
    4. UnityEditor.Modules.DefaultTextureImportSettingsExtension.ShowImportSettings (UnityEditor.BaseTextureImportPlatformSettings editor) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
    5. UnityEditor.BaseTextureImportPlatformSettings.ShowPlatformSpecificSettings (System.Collections.Generic.List`1[T] platformSettings, System.Int32 selected) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
    6. UnityEditor.U2D.Common.TexturePlatformSettingsHelper.ShowPlatformSpecificSettings () (at Library/PackageCache/com.unity.2d.common@6.0.3/Editor/InternalBridge/TexturePlatformSettings/TexturePlatformSettings.cs:158)
    7. UnityEditor.U2D.PSD.PSDImporterEditor.DoPlatformSettings () (at Library/PackageCache/com.unity.2d.psdimporter@6.0.4/Editor/PSDImporterEditor.cs:419)
    8. UnityEditor.U2D.PSD.PSDImporterEditor.DoSettingsUI () (at Library/PackageCache/com.unity.2d.psdimporter@6.0.4/Editor/PSDImporterEditor.cs:274)
    9. UnityEditor.U2D.PSD.PSDImporterEditor.OnInspectorGUI () (at Library/PackageCache/com.unity.2d.psdimporter@6.0.4/Editor/PSDImporterEditor.cs:232)
    10. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <122642d41668428d845063b1753c4e72>:0)
    11. UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    I've tried restarting Unity, reimporting the asset, and removing and reinstalling the PSD Importer but nothing works. Not sure what to do.
     

    Attached Files:

    • bug.png
      bug.png
      File size:
      365.2 KB
      Views:
      193
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    There is no call to spam your posts twice and in fact it is against forum rules. Once is adequate please!

    As usual, the correct solution is always source control so you can trivially revert.

    Barring that you will need to manually fix the problem.

    I strongly recommend you back your entire project up NOW and start using source control immediately before more destruction is wrought upon your project.

    Lost progress / project / work / stuff disappeared in Unity.

    This article is to help you when you have lost significant progress or work in your Unity project.

    It is designed to give you avenues of discovery and investigation.

    It is NOT a guarantee of restoring your lost work. It is NOT a substitute for proper IT / Data security procedures.

    To decide which parts are applicable to you, look for major bolded headings.

    EVERYTHING IS GONE, YOU CANNOT OPEN THE PROJECT

    Your project probably is still on your computer. Try a computer-wide search for some unique filenames that you know are in the project you think is gone.

    To start your search, one common file to all Unity projects is named
    ProjectSettings.asset


    Some things that might have happened:

    - you are not opening the project that you think you are

    - you are in the correct project but not opening the same scene you had open before

    - you dragged the project (or part of it) into the trash (intentionally or inadvertently)

    - you moved the project (or part of it) somewhere else (intentionally or inadvertently)

    - an overly-aggressive antivirus solution quarantined it because it saw code being compiled in there

    - you're using a directory sync like OneDrive or Dropbox... NEVER USE THESE SERVICES WITH UNITY!

    - something else??

    As I said, it's probably still all on your system to be found if you look in the right places.

    A typical Unity project will have at a minimum the following folders:

    Assets\
    ProjectSettings\
    Packages\


    EVERYTHING IS PRESENT BUT MY SCENE WINDOW IS BLANK

    Close Unity and make a full project backup RIGHT NOW. Do not do ANYTHING else until you back it up 100%.

    Ideally copy that backup to another computer, or back it up into the cloud. This is just basic data processing best practices.

    If you can see all the files and folders of your project, make sure you are opening the scene file you were working in.

    Once you have opened the scene, look in the hierarchy window, select an object and move the mouse over the Scene window and press F to focus that object.

    Additional notes:

    - ALWAYS use proper industrial grade source control (see below)
    - NEVER use Dropbox or any file sync mechanism in Unity.
    - NEVER move files within your project, except by doing it within Unity
    - ALWAYS be sure you are fully backed up before upgrading Unity

    SCRIPTS OR ASSETS ARE MISSING OR BLANK

    Some info about Missing script warnings, GUIDs, renaming GUIDs, etc:

    https://forum.unity.com/threads/problem-with-git-and-missing-scripts.1090876/#post-7024801
    https://forum.unity.com/threads/scr...ead-after-loading-editor.998413/#post-6487297
    https://forum.unity.com/threads/scr...ead-after-loading-editor.998413/#post-6488230

    EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile.

    It is super-easy to inadvertently change it by renaming outside of Unity. Don't do that. Instead:

    - close Visual Studio (important!)
    - rename the file(s) in Unity
    - in Unity do Assets -> Open C# Project to reopen Visual Studio
    - now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

    If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
    deetorz likes this.
  3. deetorz

    deetorz

    Joined:
    Sep 3, 2020
    Posts:
    5
    Thanks for the reply. You're right, I shouldn't have posted it twice. I actually was thinking about deleting the first post and I guess I will. I was just really frustrated is all. I kept telling myself I needed to setup version control with my github account but I kept pushing it back. I really appreciate your lengthy response. I need some sleep but I'll read the resources you posted more carefully tomorrow.
     
  4. deetorz

    deetorz

    Joined:
    Sep 3, 2020
    Posts:
    5
    Well, at this point, I'm not so concerned about my project being gone. I can rebuild it. I'm more concerned with the fact that this Unity version I'm using, 2021.3.9f1, seems to be broken. Even after starting a new project, I face the same problem when importing a PSB file. I tried importing the same file into a Unity project in version 2021.3.2f1 and there were no problems. I tried reinstalling the editor but that did not fix anything.
     
  5. Mitshi

    Mitshi

    Joined:
    Mar 18, 2019
    Posts:
    3
    So the best workaround I found about this is just commenting out some lines in the editor so it doesn't show the specific platform settings anymore. I don't need to make any changes there anyways, so that works for me.

    Specifically you have to delete or comment these lines in "<your_project>\Library\PackageCache\com.unity.2d.common@7.0.1\Editor\InternalBridge\TexturePlatformSettings\TexturePlatformSettings.cs"

    Lines 156 - 158

    BuildPlatform[] validPlatforms = BuildPlatforms.instance.GetValidPlatforms().ToArray();
    int shownTextureFormatPage = EditorGUILayout.BeginPlatformGrouping(validPlatforms, EditorGUIUtility.TrTextContent("Default"));
    BaseTextureImportPlatformSettings.ShowPlatformSpecificSettings(m_PlatformSettings.ConvertAll<BaseTextureImportPlatformSettings>(x => x as BaseTextureImportPlatformSettings), shownTextureFormatPage);

    Untitled-1.png

    I decided to go for Unity version 2022.1.16f1 because I need the 2D PSD Importer 7.0.2 and it has the feature "Mosaic Padding" in the inspector.

    This entire problem has nothing to do with source control btw. It doesn't work in Unity versions 2021.3.9f1, 2022.1.16f1, 2022.2.0b7 and 2023.1.0a9 with new projects. It still works in Unity 2021.3.2f1, 2D PSD Importer version 6.0.

    If anyone finds better solutions please let me and everybody else know.
     
    Last edited: Sep 15, 2022
    sgallouet likes this.
  6. deetorz

    deetorz

    Joined:
    Sep 3, 2020
    Posts:
    5
    Nice! I had thought about messing with the code but I was worried that that might lead to problems down the line somehow... In any case, my project was not so big so once I calmed down, remaking was not a huge deal. That being said, I think they need to look into this because anyone using the versions you mentioned may run into the same problem.

    I agree, version control had nothing to do with the problem. However, I completely agree with what Kurt said.. version control should always be setup when working on a project that you plan to take seriously/work on for a while. That being said... I still don't think that would have saved the day simply because this seems to be a problem with the imported package and the specific version of the editor. What a shame. Hopefully a fix will be found so others don't have the same issue!
     
  7. ville-ps

    ville-ps

    Joined:
    Sep 17, 2018
    Posts:
    2
    I found that the foldout state is stored via editor prefs so here's a way to close the foldout and fix the error
    Code (CSharp):
    1. UnityEditor.EditorPrefs.DeleteKey("PSDImporterEditor.m_PlatformSettingsFoldout");
    You can call this from some editor script:
    Code (CSharp):
    1. public static class FixPSDImporter
    2. {
    3.     [UnityEditor.InitializeOnLoadMethod]
    4.     public static void ResetPSDImporterFoldout()
    5.     {
    6.         UnityEditor.EditorPrefs.DeleteKey("PSDImporterEditor.m_PlatformSettingsFoldout");
    7.     }
    8. }
     
  8. deetorz

    deetorz

    Joined:
    Sep 3, 2020
    Posts:
    5
    This is good to know! Thanks :)
     
  9. Mitshi

    Mitshi

    Joined:
    Mar 18, 2019
    Posts:
    3
    Thank you! That's a way cleaner solution than mine.
     
  10. wusar

    wusar

    Joined:
    Oct 25, 2022
    Posts:
    1
    Thanks, it helps me a lot!
     
  11. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    did they fixed this in more recent unity versions?
     
  12. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    i will answer myself, nope they didn't fix this

    tried 2022.1.20f1

    managing options for imported files is a common task. having this bug showing up on multiple unity versions shows that unity developers don't even test the stuff they are updating/publishing

    it took me 5 minutes to create a new project, import one file, click on it, see that the bug shows up. you don't even need complex AI verification setups with logs and feedback for complex scenarios.
     
  13. Naminuz

    Naminuz

    Joined:
    Aug 12, 2015
    Posts:
    6
    Impressive that a bug that grave exist...
     
  14. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
  15. Mitshi

    Mitshi

    Joined:
    Mar 18, 2019
    Posts:
    3
    This bug was fixed in 2D PSD Importer Version 7.0.3. So no workarounds needed anymore. Here's the changelog:
    [7.0.3] - 2022-09-07
    Fixed
    • Improved import speed and memory allocation for psd/psb files by reducing the intermediate texture buffers.
    • Fixed an editor freeze caused by over allocating intermediate texture buffers. (Case DANB-140)
    • Fixed an issue where some layers would become invisible when merging multiple layers together. (Case DANB-131)
    • Fixed exception when showing PSDImporter inspector. (DANB-197)