I have been trying to use the UMG MVVM Plugin. It is a nice concept, and I have found more than a few uses outside of UMG, but as far as using it with UMG, well, it fails.
LogLinker: Warning: [AssetLog] I:\Unreal\Projects\Playground\Content\UI\UIW_DateTime.uasset: VerifyImport: Failed to find script package for import object 'Package /Script/ModelViewViewModelBlueprint'
When you create a view model on a Widget, create your bindings, compile, etc.
It is working great, but when you restart your Editor the above error happens and your Widgets no longer have the ViewModel attached, and it is asking for you to make a new viewmodel.
The current workaround I have for this is to reload your Widget. Asset Actions->Reload This will reload the ViewModel and attach it to the Widget again and you are back too:
But any nodes or blueprints that referenced that Widget are now broken and you need to go and fix them before you can play again.
Thanks, if anyone knows of a workaround or fix for this, please let me know hope this gets fixed soon.
Ok, after giving this a break for sometime, I revisited and reread the logs. I have found the location of this failure. It comes from the base c++ code this is generated by Unreal Engine in a fresh c++ project (which is likely why I didn’t find it initially). Anyways, the error happens in the GameMode.cpp that is generated for you project, when it tries to load the BP_Class for either your Character or Controller, if you try to use a widget that uses MVVM ViewModel in either of these classes it will fail to load the MVVM for the widget. I assume this is due to when it loads these classes.
As I use a BP version of my Gamemode in my game I don’t need to set these defaults, so I just removed the code and all is good now. The offending code was this:
This might need to be fixed, as this is kind of an obscure issue that effects this plugin.
This text will be hidden
My Solution did not work, it only worked because I removed the BP reference from gamemode, when I added the reference back to the BP Gamemode, the samething happens. I Would love a solution to this issue.
I had tried that, but I just solved this issue, not really sure why. I corrected a different issue, I had a struct that I failed to initialize properly in another plugin. After fixing that the issue corrected itself… I am confused, but it works.
Yes, I ran into this problem too. I have a BP_MyUserWidget, which has MVVM Viewmodel and Bindings setup. BUT as soon as I try to reference BP_MyUserWidget inside my C++ HUD class constructor, like this:
Inside my C++ HUD BeginPlay(), or wherever I actually do the CreateWidget and AddToViewport etc. etc. Doing it this way, the Viewmodel and Bindings stay properly on the Blueprint, and don’t get removed after closing and reopening the editor.
Feels like MVVM plugin should throw some kind of error when you load the Blueprint UserWidget class at a bad time though?
OK, new problem if you’re using a UserWidget with UPROPERTY(meta=(BindWidget)). Say you create a Canvas Panel like this:
and from your MVVM you’re setting up your Bindings too, then from BOTH the C++ side and the BP side, the Binding Name “MyCanvasPanel” will be occupied. And you won’t be able to package your project with the error:
Internal Compiler Error:
Tried to create a property MyCanvasPanel in scope SKEL_BP_MyUserWidget_C, but another object (ObjectProperty /Script/MyProject.MyUserWidget:MyCanvasPanel) already exists there.
from Source: /Game/UserWidgets/MyUserWidget.MyUserWidget
@tenowg I have the same problem, and I’ve solved it with change the Object Reference and Class Reference to FSoftObjectPath FSoftClassPath in my blueprints.
I found the blueprint will loading before the ModelViewViewModelBlueprint, so change to soft paths is OK.
I also struggled with the Linker error you mentioned:
The solution that works for me is to change the LoadingPhase of the ModelViewViewModelBlueprint module from Default to PreDefault. This can be done in the ModelViewViewModel.uplugin file found in the engine folder: UE_5.4\Engine\Plugins\Runtime\ModelViewViewModel\
Edit: I need to correct myself: the solution I explained above only worked partially. The linker error was gone and the widget remembered the viewmodel I assigned to it. But the editor crashed on startup whenever I bound a property to a view.
My Gamemode tried to get a reference to the MVVMSubsystem for the creation of its class default object. It turned out to be the exact same issue as described here. That gamemode class created a reference in its ctor using FClassFinder to get my BP_PlayerController. I removed that reference in the c++ class. Created a new blueprint deriving from that c++ class, and set the reference there.
In the end, everything was layed out in front of me. It was just a pain to combine all the pieces correctly. Especially, because this Gamemode was not even used in my current map. Loading Debug symbols and setting a breakpoint in FLinkerLoad::VerifyImportInner line 3489 where the UE_ASSER_LOG reports this Linker Error provided me the decisive clue.