Hi all, I’m trying to work out what EXACTLY is causing the “could not be loaded because it references scripts that are not compatible with the currently loaded ones” error when I try to load a prefab in an assetBundle.
I know all about why this is happening and what can cause it, and I’ve read this:
what I want to know is a good way of debugging the issue and seeing exactly which script references are breaking and why. I’v tried using Unity’s asset bundle browser but that doesn’t give you any info.
TNKS!
G
Also wrote a quick script to print the serializable interface of a class:
using UnityEngine;
using UnityEditor;
public class PrintSerializedObjectInterface
{
// Util to print a serialized objects interface to the Console
[MenuItem("Tools/Print Serialized Object Interface")]
static void printSerializedObjectInterface()
{
string res = "";
GameObject testGO = new GameObject();
MyComponentClass obj = testGO.AddComponent<MyComponentClass>();
SerializedObject sobj = new SerializedObject(obj);
SerializedProperty sprop = sobj.GetIterator();
res += " == MyComponentClass Serialzable Properties == \n";
while (sprop.NextVisible(true))
{
res += ("NAME: " + sprop.propertyPath + "\t\t\t\tTYPE: " + sprop.propertyType.ToString() + "\n");
}
Debug.Log(res);
}
}
Not very generalized but gets the job done
Hey I like that little script you made! I generalized it a bit more here:
using UnityEngine;
using UnityEditor;
public static class PrintSerializedObjectInterface
{
// Util to print a serialized objects interface to the Console
[MenuItem("Tools/Print Serialized Object Interface")]
static void printSerializedObjectInterface()
{
if (Selection.gameObjects == null || Selection.gameObjects.Length < 1)
{
Debug.LogWarning( "No Objects selected. Must select some GameObjects or Prefabs first, either in the scene or in the project.");
return;
}
foreach( GameObject go in Selection.gameObjects)
{
string res = "Serializable Object Interface for: GameObject '" + go.name + "'\n";
Component[] components = go.GetComponents<Component>();
foreach( Component item in components)
{
res += System.String.Format( "=> {0} properties:\n", item.ToString());
SerializedObject sobj = new SerializedObject(item);
SerializedProperty sprop = sobj.GetIterator();
while (sprop.NextVisible(true))
{
res += ("NAME: " + sprop.propertyPath + "\t\t\t\tTYPE: " + sprop.propertyType.ToString() + "\n");
}
}
Debug.Log(res);
}
}
}
Handy to have… stuck it in my Unity fun bag o tricks.
Thanks! My plan was to format the output as JSON so it would be easy to compare interfaces between unity projects etc
Keep in mind that when you run the above lister, it will give you the methods and properties that are in the project you are running it from, regardless of what properties existed at the time of asset bundle creation.
When you download an asset bundle, it does NOT have any code in it: it has references that allow the unity engine to re-link the code that it has to the object so that it runs as expected, but it is always using in-project code.