Search Unity

ArgumentNullException saving newly created sdf

Discussion in 'UGUI & TextMesh Pro' started by Mycroft__Holmes, Dec 18, 2018.

  1. Mycroft__Holmes

    Mycroft__Holmes

    Joined:
    Feb 16, 2015
    Posts:
    6
    Hello! Whenever I try and save a newly created sdf font that I generated using the Font Asset Creator, I get an ArgumentNull exception and the generated font is unusable because it doesn't have a material. The same error occurs in either 2018.3b11 or 2018.3 release

    The stack trace is below:

    ArgumentNullException: Value cannot be null.
    Parameter name: shader
    UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/Runtime/Export/Shader.bindings.cs:105)
    TMPro.EditorUtilities.TMPro_FontAssetCreatorWindow.Save_SDF_FontAsset (System.String filePath) (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs:1167)
    TMPro.EditorUtilities.TMPro_FontAssetCreatorWindow.SaveNewFontAsset (UnityEngine.Object sourceObject) (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs:937)
    TMPro.EditorUtilities.TMPro_FontAssetCreatorWindow.DrawControls () (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs:773)
    TMPro.EditorUtilities.TMPro_FontAssetCreatorWindow.OnGUI () (at Library/PackageCache/com.unity.textmeshpro@1.3.0/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs:237)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:342)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:336)
    UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean customBorder, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:363)
    UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:322)
    UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:266)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:438)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:421)
    UnityEngine.Experimental.UIElements.IMGUIContainer.HandleEvent (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:401)
    UnityEngine.Experimental.UIElements.EventDispatcher.ProcessEvent (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:511)
    UnityEngine.Experimental.UIElements.EventDispatcher.Dispatch (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:307)
    UnityEngine.Experimental.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.Experimental.UIElements.EventBase e, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:176)
    UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:245)
    UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:68)
    UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Make sure you have installed the TMP Essential Resources prior to trying to create a font asset. You can manually import these resources via the "Window - TextMeshPro - ..." menu option.

    These material use shaders contained in the TMP Essential Resources so if these haven't been imported then you'll get an error.
     
  3. Mycroft__Holmes

    Mycroft__Holmes

    Joined:
    Feb 16, 2015
    Posts:
    6
    I tried that, and then tried again with creating a font asset before posting here, but it didn't seem to work any better the second time. I tried that again now, and I realize it won't let me select the shaders folder when I try and import. I try and click on any of the highlighted checkboxes, or on the all button, and it just doesn't do anything: https://imgur.com/a/xPO6mPq

    I do appear to already have them in my project, though.
     
  4. Mycroft__Holmes

    Mycroft__Holmes

    Joined:
    Feb 16, 2015
    Posts:
    6
    Update: I was able to successfully create a new font asset in a new project in which I did nothing but run "Import Essential TMP Resources", import the source font, and then create a new font asset.

    However, when I export that asset as a package, and then try and import it into my actual project, it no longer appears good, and I get the same errors I got before about the lack of material. It's like the TMP assets aren't actually available in my project, despite appearing to be imported.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Does your (other project) already include the TextMesh Pro package? The other project would also need to contain the TMP Essential Resources.

    Does your other project use the same package manager version of TextMesh Pro? If your other project contains the older source code or dll versions of TMP, the newly created font assets, material and shader will be referencing the GUIDs and FileIDs used by the package version of TMP.
     
  6. Mycroft__Holmes

    Mycroft__Holmes

    Joined:
    Feb 16, 2015
    Posts:
    6
    Both projects reference "com.unity.textmeshpro": "1.3.0" in their manifest.json. Both projects were created using the new project wizard in UnityHub using the 2D project template, and supported TMP right out of the box.

    I can also confirm that the font asset I created in the new project works *in that project* just fine.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I am assuming you are using the same version of Unity between both projects. Correct?

    In your normal project, are the TMP Essential Resources located in the "TextMesh Pro" folder and the Shaders in "TextMesh Pro/Resources/Shaders/..."?

    Do existing font assets (the ones included with TMP) work in your normal project?
     
  8. Mycroft__Holmes

    Mycroft__Holmes

    Joined:
    Feb 16, 2015
    Posts:
    6
    Same version of Unity in both projects, now. Though the project that is having problems was originally created with 2018.3 beta 11.

    All the resource files appear to be in the same places, and identical. I diffed the directories and it's all matches except the font files themselves, which I have edited slightly. Screenshot of the directory diff: https://imgur.com/a/ZSyJJlj

    The default LiberationSans font asset works in both projects.
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Just to recap and make sure I am not overlooking anything.

    In the old project, creating any font asset results in the above error even when the TMP Essential Resources have been imported in the project?

    If so, can you submit a bug report with that project so I can take a look at why this error occurs?
     
  10. RGV

    RGV

    Joined:
    Jan 25, 2016
    Posts:
    48
    Happening to me right now. Unity 2019.2.11f1. TMP successfully imported and working since the beginnings, creating new font not working. ArgumentNullException, param name: shader.
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    What version of TMP are you using?

    Make sure you are using the latest release which is version 2.1.0-preview.8 for Unity 2019.x. Preview 9 will be available this week.

    Are you getting this error when using the Font Asset Creator or when creating font assets dynamically?