Unity AssetBundles for VaM 1.xx

Guides Unity AssetBundles for VaM 1.xx

MacGruber

Invaluable member
Developer
Wiki Contributor
Featured Contributor
Messages
1,607
Reactions
3,169
Points
143
MacGruber submitted a new resource:

Unity AssetBundles for VaM 1.xx - How to export content from Unity into VaM. Includes ready-to-go Unity project, ProBuilder + ProGrid.

After some people essentially begged me to do it, I spend several evenings this week and the this entire Saturday on writing a tutorial on Unity AssetBundles. It ended up to be an 13 page PDF of 2700 words. Lots of pictures, obviously.

This tutorial covers:
  • Installing the correct Unity version
  • Setup your Unity project. I have included an almost ready-to-go Unity project.
  • Getting some Assets. This is not VaM specific and therefore only covered briefly. The...

Read more about this resource...
 
This is a great guide. I am converting a DaZ asset into VAM. I output the asset as fbx format at first and load it into unity set the mesh collider (it is a room, and a tone of work on setting each component collider) but when I am dragging it into the assetbundle window, there is no texture, material, and normal files in the window, so when I am loading it in VAM, there is nothing in the atom file. Is there anything different on fbx format?
 
This is a great guide. I am converting a DaZ asset into VAM. I output the asset as fbx format at first and load it into unity set the mesh collider (it is a room, and a tone of work on setting each component collider) but when I am dragging it into the assetbundle window, there is no texture, material, and normal files in the window, so when I am loading it in VAM, there is nothing in the atom file. Is there anything different on fbx format?
Make sure you turn it into a prefab first. See the "Creating a Prefab" section in the guide
 
I'm having a similar issue to ConCquent, except my assetbundles window shows my materials. My CUA loads unlit black in VAM. It also seems like my collision is messed up, I'm using a small capsule collider.
 
Last edited:
@ConCquent @AlienPolygon Unity fails to import materials for some FBX. Don't know why. Maybe you can try fiddle with the import settings, but usually I just create my own new material(s) and assign them to the meshes. Pick one of the standard shaders and assign the textures you got to the slots.
 
@ConCquent @AlienPolygon Unity fails to import materials for some FBX.

This is a failure during import and caught before setting up the asset and converting it, right? My issue is once it loads into VAM. I'll try creating new materials instead of using the imported ones.

Tried this and got another model seemingly without materials in VAM
 
Last edited:
This is a failure during import and caught before setting up the asset and converting it, right? My issue is once it loads into VAM. I'll try creating new materials instead of using the imported ones.
Yes. I was talking about importing into Unity. If it is looking correct in the UnityEditor already, it's some different problem.
Are your objects completely black in VaM or just too dark? If that's the case, check your texture import settings (sRGB vs. Linear color space)

Otherwise, making SURE you use the correct UnityEditor version is always a good safety tip. If you use a newer version than the ancient version VaM is using, stuff will be broken. You need Unity 2018.1.9f2.
 
Are your objects completely black in VaM
Thanks for your response. Yes, my objects are completely black and absorbing light it seems. The only way I could view their material was by adding an emission to the standard material. I am on the correct version of Unity following your guide, and will check the texture import settings, though I was using albedo colors without a texture for my first attempts.
 
I should note this also happens with the sofa provided. I'm trying 2018.1.9f1 as it is in one of the screenshots, though the project is for f2.

-- it seems the scene had lighting issues, some objects appeared lit, while others didn't get any from the environment HDRI light...
 
Last edited:
Thanks for the good tool. I have built several map CUA and works well. The only trouble I have is usually parts are moved instead of the whole map while moving the CUA in VAM. Would you please help what may be the reason?
 
Thanks for the good tool. I have built several map CUA and works well. The only trouble I have is usually parts are moved instead of the whole map while moving the CUA in VAM. Would you please help what may be the reason?
The CustomUnityAsset atom loads one single object out of an AssetBundle. That you can then move around in VaM. If you want parts of your scene to be movable independently, you need to split your objects into multiple prefabs in Unity and use multiple CUA to load them. You can have multiple prefabs in a single AssetBundle, though. E.g. see "SecretRoom".
 
The CustomUnityAsset atom loads one single object out of an AssetBundle. That you can then move around in VaM. If you want parts of your scene to be movable independently, you need to split your objects into multiple prefabs in Unity and use multiple CUA to load them. You can have multiple prefabs in a single AssetBundle, though. E.g. see "SecretRoom".

Thanks! But I only need one object, the whole scene, is movable in VAM. But only partial of the scene is moved. I could not figure out why.
(While moving the asset, only the cover is moved.)
圖片 001.jpg
 
Last edited:
Looks like most of your scene is marked as "static" in UnityEditor. It gives you some performance improvement, but the downside is that objects can't be moved. Also things like lightmaps will not work without. In general, larger objects like buildings should always be static, as the player would not move them anyway.
 
Looks like most of your scene is marked as "static" in UnityEditor. It gives you some performance improvement, but the downside is that objects can't be moved. Also things like lightmaps will not work without. In general, larger objects like buildings should always be static, as the player would not move them anyway.
I disabled the static and making the asset. However, while moving the asset in VAM, only the cover moved.
Create another folder, saving a prefab, and making the asset works. (the whole scene could be moved)
But it loses the lightmap (seems a old Unity problem).
 
Hello MacGruber. First of all: Thank you so much for this guide. It was really helpful :)
However, I don't get the "Collision Part".
I tried all day long to add collision and tried sooo many different approaches. No matter what I do, when I put the asset into VAM the person either kicks the bed away. Or the person won't sit/lay on the bed but will sit/lay inside of it. I am so exhausted....and it's probably just a small thing that I just don't get, because I am compeltely new to this:/ Do you know how exactly one adds collision to the object? And I did not understand where one puts the 1 or the 0.5 that you described in the guide.
 
Do you know how exactly one adds collision to the object?
The easiest way would be to add a "Mesh Collider" component to all your GameObjects that have a mesh (= "Mesh Filter" component).
You could also try using one or a few "Box Collider" or "Sphere Collider" instead, if your object has such a simple shape.

And I did not understand where one puts the 1 or the 0.5 that you described in the guide.
That section is about using a separate mesh for collision that is different from the one used for rendering. Obviously that requires actually having such a mesh...in probably 99% of cases you would have to break out Blender/3DSMax/Maya and make such a mesh yourself. However, this can improve performance, if your mesh used for rendering has lots of triangles. Also, as said in the tutorial, you can make the collision mesh slightly smaller so the character appears to shink in slightly.
 
Thank you for the answer. It was helpful :)

Now I imported an environment in VAM but unfortunately the view is very weird in VR. I have to squint one eye to see everything normally (everything else in VR is fine...it's just the environment that's weird). However, on the desktop screen everything seems fine with the environment.
Do you know what that could be? Do I have to "insert" an extra angle or so, so that it will be normal?
 
Last edited:
Now I imported an environment in VAM but unfortunately the view is very weird in VR.
It means you didn't follow the guide and use the example project as a base.
Besides the correct Unity verison, there are a number of project settings you need that differ from Unity defaults:
  • Set project Color Space to Linear to get proper lighting. This is found in Edit->Project Settings->Player. Then click Other Settings tab. Set Color Space->Linear (default is Gamma)
  • Turn on VR support and set to single pass. This is found in Edit->Project Settings->Player. Then click XR Settings tab. Click Virtual Reality Support checkbox. The set Stereo Rendering Method->Single Pass.
 
I tried making a unity assetbundle with sounds only to use the SoundFromAB plugin. Unfortunately I keep getting this error when I try loading it into VaM:


!> System.ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
at MacGruber.SoundFromAB.OnAssetBundleLoaded (MeshVR.AssetBundleFromFileRequest aRequest) [0x00000] in <filename unknown>:0

Things I have done:
1. I have downloaded the exact version of Unity in the pdf
2. I moved all the .ogg files to the assetbundle
3. created it
4. copied it with the vamexporter tool to vam and added .assetbundle as an extension to the filename
5. tried to load it in vam, and then I get these errors

I also tried doing this, with first moving the sounds to the main unity window. This will show a play icon in the middle. And then I tried the saving of the assetbundle again. Which didn't work either...

I'm at a loss :(.

EDIT: Ok, so I finally got something. I have been able to create .prefab files for each soundfile. And then create an assetbundle. If I open the CustomUnityAsset with that filename, I can click the .prefab soundfiles from the dropdown menu in CustomUnityAsset. But I can't seem to use SoundfromAB on that file. It just won't do anything.
 
Last edited:
@pinosante Any chance you got your sound file directly in your Unity project folder, so no subfolders? If yes, please try put your sound files into one or more subfolders before adding them to the bundle. Congrats, you found a bug ? (Probably won't push a release to fix this, though.)
 
@pinosante Any chance you got your sound file directly in your Unity project folder, so no subfolders? If yes, please try put your sound files into one or more subfolders before adding them to the bundle. Congrats, you found a bug ? (Probably won't push a release to fix this, though.)
Awesome, this works! I added the files to a Sound folder I created and then created an asset from that folder.

So hey, I found a bug! Do I win anything?
 
Hi I keep getting this error and I'm not sure how to proceed.

Error in build
UnityEngine.Debug:Log(Object)
AssetBundleBrowser.AssetBundleDataSource.AssetDatabaseABDataSource:BuildAssetBundles(ABBuildInfo) (at Assets/AssetBundles-Browser-1.7.0/Editor/AssetBundleDataSource/AssetDatabaseABDataSource.cs:90)
AssetBundleBrowser.AssetBundleBuildTab:ExecuteBuild() (at Assets/AssetBundles-Browser-1.7.0/Editor/AssetBundleBuildTab.cs:359)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()
 
I am using version 2018.1.9f2 is that the wrong one? I'm using AssetBundles-Browser-1.7.0 as well.
 
Back
Top Bottom