hi all!
I load some prefabs from assetbundles and the scripts inside are not merged into the bundle, so I have this situation:

My question is:
it’s possible by script detect the missing script names?
cycling to the gameobject components I obtain only that are 2 null components…
I wish retrieve that one is ReplayCameras and the other is LayoutTick
thanks in advance!
Hm, well, the script names are LayoutTick and ReplayCameras!? ![]()
Show your code for this. Maybe we can help adapt it.
I use this:
https://github.com/liortal53/MissingReferencesUnity/blob/master/Assets/Editor/MissingReferencesFinder.cs
@Duugu my eyes understand the name, but via script is another thing ![]()
I believe that’s exactly what the code is doing. The names are then printed to the Debug.Log.
Can you explain a bit more what you want to do with these? You want to verify that these are the missing references? Only check the ReplayCameras reference?
You’d have to do it manually. Drop the script back into the component.
so, the log tell me this, no reference about the missed script name…
I want to do this, 'cause I’ve got a dll that contains these scripts and I wish replace the scripts (missed) with the scripts loaded from the dll…
Interesting. I’m not sure if that’s possible but if it is, it would have to interact directly with the prefab - iterating over the attached components. I can’t seem to determine the type of component that is missing by the time we instantiate a GameObject.
If the prefab has a reference, it should be possible to either: detect directly on the prefab that the component is missing, or otherwise, compare the expected components (on the prefab) to the actual components (on the instance). It might then be possible to edit the prefab directly, or simply add new components to every instance of the GameObject from your external library.
I’ve seen some other’s post regularly here that seem interested in this kind of stuff and know the Unity framework a lot better than I. Maybe one of these guys can help: @Kiwasi @StarManta @lordofduct
Flattered! But a quick play with this in Unity gave me nothing.
thanks for the interest mates…
but is not possible inglobe the scripts in asset bundle? this solve everything ![]()
Because of the recompile from unity c# to C++ binaries (ie. think what happens -either when using Editors or Play in UI )- asset bundles don’t include scripts - they are part of the game code proper - so the recompiled bits necessitate a game code update - not just an asset bundle added.
There are some tutorials in Unity3d live learning - I believe the name is “Working with Asset Bundles in Unity 5” or look at some of the Custom Editor tutorials.
Is the image in the first post accurate?
If a script can’t be found, it usually doesn’t say the name of the script. The way scripts are referenced in the serialized data does not store the name of the script, but instead it stores a guid that is generated for the script, unless it’s in a dll, in which case it’s referenced by the guid associated with the dll and an md4 hash of the class name for the script in the dll (if you need this information I have it).
In the image though, that’s not what I usually see if I’m missing the script reference. But instead if there was errors in my code that caused the serializer to stop deserializing a prefab before it got to that script. Some code somewhere threw an exception, the deserializer haulted. That’s why your inspector says:
Note that first line. It’s not saying the script is missing. It’s saying it can’t be loaded.
Sure… we might be able to repair this on the fly (I’ll need more information, depending your situation)… but it’s really a sign of an existing underlying issue with your program. That should be fixed instead.
That is, if the image in OP is accurate.
hello!
Thanks for your interest… the image is accurate, and here are the steps:
in my other project I select some gameobjects and I create a prefab, and this prefab I export into an assetbundle.
in my project I load this prefab into a gameobject and if I don’t have the script inside my project, the result is like the image in the old posts…
how are you exporting it into an assetbundle?
how are you loading it in the other project?
Also… of course if the project you load it into doesn’t have a script, it’s going to say it can’t find the script. It doesn’t exist. There’s no finding out what script is missing and what not, it’s not there, there’s no way to add it.
here is how I export:
static void CreateTrackMenu ()
{
string path = EditorUtility.OpenFolderPanel("Save Track", "", "");
if (!string.IsNullOrEmpty(path))
{
// first, create the prefabs
List<string> prefabNames = new List<string>();
foreach (var item in Selection.gameObjects)
{
string name = item.name;
prefabNames.Add(name);
string prefabName = "Assets/" + name + ".prefab";
Object prefab = PrefabUtility.CreateEmptyPrefab(prefabName);
PrefabUtility.ReplacePrefab(item, prefab);
AssetDatabase.Refresh();
}
foreach (var item in AssetDatabase.GetAllAssetBundleNames())
{
Debug.Log(item + " deleted!");
AssetDatabase.RemoveAssetBundleName(item, true);
}
AssetBundleBuild[] buildInfo = new AssetBundleBuild[prefabNames.Count];
for (int i = 0; i < prefabNames.Count; ++i)
{
buildInfo[i] = new AssetBundleBuild { assetBundleName = prefabNames[i] + ".unity3d",
assetNames = new [] {"Assets/" + prefabNames[i] + ".prefab"}};
}
//AssetImporter carImporter = AssetImporter.GetAtPath("Assets/" + name + ".prefab");
//carImporter.assetBundleName = name + ".unity3d";
BuildPipeline.BuildAssetBundles(path, buildInfo);
}
}
}
and here is how I load:
public IEnumerator LoadTrackWithLayout()
{
// load manifest
var wwwManifest = new WWW(manifestFile);
yield return wwwManifest;
AssetBundle manifestBundle = wwwManifest.assetBundle;
AssetBundleManifest manifest = (AssetBundleManifest)manifestBundle.LoadAsset("AssetBundleManifest");
// get dependencies
string[] dependentAssetBundles = manifest.GetAllDependencies ("main.unity3d");
for (int i = 0; i < dependentAssetBundles.Length; ++i)
{
Debug.Log(dependentAssetBundles[i]);
}
// load dependencies
AssetBundle[] assetBundles = new AssetBundle[dependentAssetBundles.Length];
for (int i = 0; i < dependentAssetBundles.Length; ++i)
{
string assetBundlePath = GRUtility.Instance.GetWWWPath(trackPath + "/" + dependentAssetBundles[i]);
// hash
Hash128 hash = manifest.GetAssetBundleHash(dependentAssetBundles[i]);
var www = WWW.LoadFromCacheOrDownload(assetBundlePath, hash);
yield return www;
assetBundles[i] = www.assetBundle;
}
GRConfig.Instance.TrackHash = manifest.GetAssetBundleHash("main.unity3d");
var wwwTrack = WWW.LoadFromCacheOrDownload (GRUtility.Instance.GetWWWPath(trackPath + "/" + "main.unity3d"), GRConfig.Instance.TrackHash);
yield return wwwTrack;
AssetBundle trackBundle = wwwTrack.assetBundle;
var rallyTrack = (GameObject)Instantiate(trackBundle.LoadAsset("main"));
if (rallyTrack != null)
{
GRConfig.Instance.TrackLayoutHash = manifest.GetAssetBundleHash("layout" + layout.ToString() + ".unity3d");
var wwwLayout = WWW.LoadFromCacheOrDownload (GRUtility.Instance.GetWWWPath(trackPath + "/" + "layout" + layout.ToString() + ".unity3d"), GRConfig.Instance.TrackLayoutHash);
yield return wwwLayout;
AssetBundle layoutBundle = wwwLayout.assetBundle;
var rallyLayout = (GameObject)Instantiate(layoutBundle.LoadAsset("layout" + layout.ToString()));
if (rallyLayout != null)
{
rallyLayout.transform.parent = track.transform;
track.IsLoaded = true;
}
}
// unload dependente
for (int i = 0; i < dependentAssetBundles.Length; i++)
{
assetBundles[i].Unload(false);
}
// unload cube assetbundle
trackBundle.Unload (false);
}
after this, the script is not loaded, but the gameobject mantain some reference, 'cause the shot above tell me the right name of the missing script