- Home /
This question was
closed Mar 23, 2017 at 03:47 PM by
Liam_B for the following reason:
The question is answered, right answer was accepted
Question by
Liam_B · Mar 22, 2017 at 07:05 AM ·
gameobjectinstantiatedestroyassetbundle
Destroying Instantiated Prefab from AssetBundle
Hello!
A bit of a last resort after spending the past week or so trying to find a solution via the forums, I'm able to instantiate a model within the parent GameObject, however I'm having trouble destroying the object after its been used. Heres the code used to download and instantiate the model (Which works fine, just unsure whether some may need reworking for the destroy to work).
while (!Caching.ready)
yield return null;
var www = WWW.LoadFromCacheOrDownload(mARData.ModelUrlAndroid, mARData.TargetVersion);
yield return www;
bundle = www.assetBundle;
if (!string.IsNullOrEmpty (www.error)) {
Debug.Log (www.error);
}
else {
model = (GameObject)bundle.LoadAsset(mARData.ModelName);
model = Instantiate(model);
model.transform.parent = AugmentationObject.transform;
model.transform.localPosition = new Vector3(mARData.PositionX, mARData.PositionY, mARData.PositionZ);
model.transform.localRotation = Quaternion.Euler(mARData.RotationX, mARData.RotationY, mARData.RotationZ);
model.transform.localScale = new Vector3(mARData.ScaleX, mARData.ScaleY, mARData.ScaleZ);
model.name = mARData.ModelName;
www.assetBundle.Unload(false);
mIsLoadingModel = false;
Any help/links would be greatly appreciated!
Comment
Best Answer
Answer by Liam_B · Mar 25, 2017 at 08:53 AM
Okay seemed to fix the issue in the end, before exporting the asset bundle I assigned a Tag to the object, which then I was easily able to find and destroy the object with :)