我在脚本中实例化了一个预制件。创建的GameObject在项目视图中没有来自我的预制件的任何组件。我的预制件假设有一个脚本组件,但是当我实例化它时它没有。它怎么可能发生?
IEnumerator StartDownload()
{
WWW www = new WWW(Application.StreamingAssetsPath() + "/shadow.unity3d");
yield return www;
AssetBundle ab = www.assetBundle;
AssetBundleRequest abr = ab.LoadAsync("shadow", typeof(GameObject));
yield return abr;
GameObject tmp = abr.asset as GameObject;
LoadShaderAgain myScriptComponent = tmp.GetComponent<LoadShaderAgain>();
if (myScriptComponent == null)
{
Debug.LogError("losing the script compoent");
}
GameObject obj = GameObject.Instantiate(tmp);
}