playMaker

Author Topic: Prefabs should have exactly 1 root GameObject error during build  (Read 1746 times)

mech_alina

  • Playmaker Newbie
  • *
  • Posts: 8
Getting the error Could not load Prefabs content at path....Prefabs should have exactly 1 root GameObject. We haven't been doing anything to the prefab. The game runs in the editor but only appeared when trying to build to Android. How do we go ahead and fix this?

This was happening to one prefab that we couldn't figure out, had to delete the whole prefab and recreate it from scratch to fix it. Now this is happening to multiple prefabs in the game. Our hunch is also it may be because of weird merging things using PlasticSCM.

Example of one of the errors:

Code: [Select]
ArgumentException: Could not load Prefab contents at path Assets/Prefabs/FitBook/Box Holder.prefab. Prefabs should have exactly 1 root GameObject, 2 was found.
UnityEditor.PrefabUtility.LoadPrefabContents (System.String assetPath) (at <091d339d138346aa90aa98b5607c9126>:0)
HutongGames.PlayMakerEditor.ProjectTools.GetPrefabGameObject (System.String prefabPath) (at Assets/PlayMaker/Editor/PlayMakerProjectTools.cs:152)
UnityEngine.Debug:LogException(Exception)
HutongGames.PlayMakerEditor.ProjectTools:GetPrefabGameObject(String) (at Assets/PlayMaker/Editor/PlayMakerProjectTools.cs:159)
HutongGames.PlayMakerEditor.ProjectTools:DoPreprocessPrefabFSMs(List`1) (at Assets/PlayMaker/Editor/PlayMakerProjectTools.cs:278)
HutongGames.PlayMakerEditor.ProjectTools:DoPreprocessPrefabFSMsInBuild() (at Assets/PlayMaker/Editor/PlayMakerProjectTools.cs:115)
HutongGames.PlayMakerEditor.ProjectTools:PreprocessPrefabFSMs() (at Assets/PlayMaker/Editor/PlayMakerProjectTools.cs:57)
HutongGames.PlayMakerEditor.PlayMakerPreProcessBuild:OnPreprocessBuild(BuildReport) (at Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs:31)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)


Details:
Unity 2021.2.9f1
Playmaker 1.9.4
Android platform

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Prefabs should have exactly 1 root GameObject error during build
« Reply #1 on: August 10, 2022, 06:33:54 AM »
Hi.
You can try removing the meta file and restart unity.
or do reimport all (this may take a look time depending on the project size)

Its very possible PlasticSCM causes issues with it, as with Unity Colaborate there are also issues.

i am using github for several years now and this one so far works best for me.

mech_alina

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Prefabs should have exactly 1 root GameObject error during build
« Reply #2 on: September 09, 2022, 06:33:38 PM »
Thanks for the reply! How I ended up fixing it was there was an extra line of code in the file for the GUID. Definitely looks like it is caused by plastic.