- Home /
PrefabUtility.ApplyPrefabInstance throws error when there is Script that does not directly derive on MonoBehaviour
I have two of buttons (MenuRaceButton and MenuChallengesButton) in my menu prefab that do not directly derive from MonoBehaviour. They derive from my own WS_MenuButton, which then derives from MonoBehaviour. So there is chained inheritance (if this is the correct term..) to MonoBehaviour.
I try to apply prefab changes in and editor script with PrefabUtility.ApplyPrefabInstance but it throws two (2) errors. You are trying to replace or create a Prefab from the instance 'ui_button_race' that contains the script 'MenuRaceButton', which does not derive from MonoBehaviour. This is not allowed. Please change the script to derive from MonoBehaviour or remove it from the GameObject.
and
You are trying to replace or create a Prefab from the instance 'ui_button_challenges' that contains the script 'MenuChallengesButton', which does not derive from MonoBehaviour. This is not allowed. Please change the script to derive from MonoBehaviour or remove it from the GameObject.
It seems that this might be a bug in the PrefabUtility, as both of the scripts derive from MonoBehaviour, but the Prefab Utility does not recognize the "chained" inheritance case properly.
br -Pauli / Kuuasema
Your answer
Follow this Question
Related Questions
How to find the prefab base of a Prefab Variant through code? 1 Answer
How to (in code) save a gameobject that already exists in my scene as a prefab? (c#) 0 Answers
Game Object is Instantiating on same position 2 Answers
Unity automatically "applies prefab changes" to selected GameObject when going to Play mode 1 Answer
prefab instantiated by script containing ShadowCaster2D bugs out 0 Answers