- Home /
Cannot build asset bundle of a terrain with trees placed
Hi,
I'm quite newbie in Unity but trying to learn as fast as my free time lets me. I'll try to be concise:
I have a unity 3D player that someone has made for me. I aim to load a scene that I make to this player, where I can mainly move the camera or rotate it. The way to load the scene is with asset bundles, but I'm having trouble to create them.
I have started from the most basic terrain, and, till now, I have been able to build (as asset bundle) a simple terrain with a grass texture and raisings. The next step has been to place trees, but I've spotted with the following error:
Building AssetBundle failed because hash collision was detected in the deterministic id generation. Conflict happened between Asset "Assets/Standard Assets/Environment/SpeedTree/Conifer/Conifer_Desktop Materials/LOD2/Branches_0.mat" and "Assets/Standard Assets/Environment/SpeedTree/Palm/Palm_Desktop Materials/LOD2/Branches_0.mat". UnityEditor.BuildPipeline:BuildAssetBundles(String, BuildAssetBundleOptions) CreateAssetBundles:BuildAllAssetBundles() (at Assets/Export.cs:12)
Trying to solve this problem I've googled for it and have found that it may be solved adding to the export.cs script the following parameter
BuildAssetBundleOptions.DeterministicAssetBundle
which I have added to no avail:
using UnityEditor;
using System.IO;
public class CreateAssetBundles
{
[MenuItem ("Assets/Build Asset Bundles")]
static void BuildAllAssetBundles ()
{
if (!Directory.Exists("AssetBundles") )
Directory.CreateDirectory ("AssetBundles");
BuildPipeline.BuildAssetBundles ("AssetBundles", BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.DeterministicAssetBundle);
}
}
I've also tried loading just that parameter and not the Uncompressed one, but I've had the same result.
So the next thing I have tried has been to remove the files that are colliding. Let's say there are three LOD folders in which the files have the same names, I have removed two of those folders. The problem is that now I can't see the trees due to what I've done.
Do you know if there is any way to export assetbundle with these kind of trees or whatever objects I place in my terrain that have same names for different levels of detail? If not, is there anyway that I could rename those LODs withoud spending much time?
My next steps, if this scene would be exported successfully, was goint to be adding skybox, fog, wind, maybe moving animals or such. Will I have further problems exporting all those as assetbundle so my player will be able to work with that?
Thank's a lot in advance for your help!!
Kind regards.
I've found another obstacle while trying to build another AssetBundle.
I removed the trees and tried with a water table, but when I click on Build AssetBundle I get a $$anonymous$$icrosoft Visual C++ Runtime Library Error (I attach the screenshot). Do you have any idea about how to solve this??
View post on imgur.com
I think you were on the right lines. The reason you can't see some of the trees after removing the duplicate(s) is that you've removed the material they were using. You probably just need to apply the other material (the one you haven't removed) to those trees in its place. I'm assu$$anonymous$$g that these materials are identical (hence the hash confusion).
The problem is that I can't see any of the trees. The logic thing was that I would be able to see them just from a fixed distance or something like that but I can't at all, maybe I'm doing something wrong.
I've been suggested by Unity support to generate those trees dinamically on runtime, the problem is that that wouldn't work with the player I have, I just can pass the scene as AssetBundle, so hope sooner or later there will be a fix for this.
Thank's for your suggestion Bonfire!
Answer by xexijreil · Oct 28, 2015 at 12:50 PM
I've been looking for a solution and still trying other parameters of BuildPipeline but still no clue about how to solve it.
I've found this: http://issuetracker.unity3d.com/issues/assetbundle-collision-when-building-assetbundles
So I suppose this is a kind of unity bug and we'll going to have patience till it's solved. Anyway still hoping anyone have found a workaround for this and can help me.