I'm using Unity 2018.6.3
I have a ScriptableObject and I placed instances of it into an AssetBundle. The issue I have is that it loses all data except its name string.
Here's a simple version of what I'm trying to do:
public class MyScriptableObject : ScriptableObject
{
public string Name; // this data remains fine
public GameObject Item; //this data is lost when AssetBundles are built
public List = new List(); //contents of this list is also lost
}
[Serializable]
public class ItemHolder
{
public string ItemName;
public GameObject SecondItem;
}
When I load an instance of this ScriptableObject from the AssetBundle, the Name string comes back, but all the other references are lost.
The scriptable object asset and the prefab are inside the AssetBundle.
Is there something I'm doing wrong?
↧
ScriptableObject losing data in AssetBundle
↧
Shader/Material not displaying properly when attached model loaded from bundle
Android project
Unity 2018.3.0f2
Hey there!
I've got a hexagon tile prefab loading from an asset bundle, but it looks like the materials are displaying slightly differently than if the prefab is embedded.
I've tried a few things including preloading a ShaderVarientCollection that includes the shader and always including the shader in the graphics settings. That doesn't seem to have changed anything.
When I go into the editor in play mode and swap out the instanced materials with the original materials it fixes the issue so it seems like something with loading the materials but I'm not sure how to fix it.
Below on the left is the embedded prefab in the scene, and on the right is when the prefab is loaded from the asset bundle.
![alt text][1]
[1]: /storage/temp/134068-screen-shot-2019-03-02-at-154627.png
Thanks,
Kate
↧
↧
Failed to decompress data for the AssetBundle 'Memory.
This is my code but whenever I run it I get this error. Is it even possible to instantiate an object from outside of the Unity Project and if so how can I do that? Is
void Start()
{
WWW www = new WWW(url);
AssetBundle assetBundle = www.assetBundle;
GameObject bundle = assetBundle.LoadAsset("Heart", typeof(GameObject)) as GameObject;
Instantiate(bundle);
}
↧
Is there a way to set the Addressables Remote Load Path in runtime?
We'd like to have several copies of the builded addressable bundles online (for backup purposes). Is there a way to switch the remote load path in runtime without consequences?
↧
How can we clean a material whenever there's a shader change
We use the asset bundle for our project. We encountered an issue with the materials. If we create a material with a shader like standard shader, we place a texture in the material. We change the shader in the material by Unlit/Color (With no texture). We save. If we put the material in the asset bundle browser, the material will always reference the texture and this texture will be added in the asset bundle. How can we clean the material ?
↧
↧
Random Crashes (SIGSEGV) on Android Huawei devices - (maybe linked to AssetBundles and/or Textures)
Hello,
We're having a lot of crash reports of the same type from the Google Play Console showing some errors causing the app to crash, but only for devices of a specific brand (Huawei).
One example of report is attached below. Basically, all the reports have the same shape: the exception can occur at any place in our code, then it always results in the same "java.lang.Error" in UnityMain process.
The weird thing is (and I don't think it's a coincidence) the complete list of devices shows exclusively devices of the Huawei brand.
Any idea of what could cause such errors on specific devices?
Thanks a lot!
java.lang.Error: signal 11 (SIGSEGV), code -6 (?), fault addr 00001058
Build fingerprint: 'HUAWEI/WAS-LX1A/HWWAS-H:8.0.0/HUAWEIWAS-LX1A/363(C02):user/release-keys'
Revision: '0'
pid: 4450, tid: 4517, name: UnityMain >>> com.my.app <<<
r0 00000000 r1 0000106c r2 0000000b r3 cfe9bc18
r4 cfe9bc18 r5 c65166d0 r6 c24032b8 r7 0000010c
r8 cb55c038 r9 cfa30f44 sl cfa30f44 fp ce80d5ac
ip a4507528 sp ce80d5a8 lr cfda7d54 pc f2f973ac cpsr 2d534157
at libc.tgkill(tgkill
at libmono.0029ed50 (Native Method)
at libmono.0029ee4c (Native Method)
at libmono.0029eea8 (Native Method)
at libmono.00116374 (Native Method)
at libmono.00116610 (Native Method)
at libmono.0011f65c (Native Method)
at libmono.0001ce04 (Native Method)
at libmono.0001e91c (Native Method)
at libmono.0001fbf0 (Native Method)
at libmono.00020914 (Native Method)
at libmono.00020b14 (Native Method)
at libmono.mono_compile_method (mono_compile_method:84)
at libmono.000ea154 (Native Method)
at Unknown.00002054 (Unknown Source)
at MyMethod (Native Method)
...
↧
How to load scene additively and keep Occlusion Culling Data?
When I load a scene additively, it says it has no Occlusion Culling. This occurs in 2018.2.20f1. I load the scene from an asset bundle. Any ideas?
↧
Noob question about AssetBundle (iOS)
Hello,
I'm a beginner in Unity dev for a iOS augmented reality app.
Here's the context: the app has a dropdown menu to give users access to various levels based on scenes in the build.
Currently, I have serialized an asset with 2 arrays: 1 for all scenes names in the build (scenesName) and 1 for the ones enabled in the build (scenesEnabled). So I can add them as dropdown menu options if they're enabled.
It works fine inside Unity, I can populate the dropdown menu with the scenes checked in the build window.
Of course, once on iOS, it needs to be in an assetbundle. So I used the "AssetBundles Browser" from Unity to create it.
On my iPhone, it seems I can access to the asset inside the bundle through my code, but I don't know how to load objects inside the asset to be able to use them. I mean the problem is "how to access object inside bundle, not use the object itself"
So, if someone would help me, it would be very nice !
Here's my code:
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
using System.Text.RegularExpressions;
public class RetrieveBuiltScenes : MonoBehaviour
{
private string sceneName;
TMP_Dropdown DropDownHome;
// Name of my assetbundle
string nameOfAssetBundle = "buildscenesassetbundle";
// Name of my asset
string nameOfObjectToLoad = "ScenesList";
private void Start()
{
// Dropdown menu definition and Regex to keep only needed string from scenes name
DropDownHome = GetComponent();
DropDownHome.ClearOptions();
Regex regex = new Regex(@"([^/]*/)*([\w\d\-]*)\.unity");
// Loading my assetbundle
var myLoadedAssetBundle = AssetBundle.LoadFromFileAsync(Application.dataPath +"/Raw/" + nameOfAssetBundle);
if (myLoadedAssetBundle.assetBundle == null)
{
Debug.Log("Failed to load AssetBundle!");
return;
}
else
{
// Loading my asset
var assetLoadRequest = myLoadedAssetBundle.assetBundle.LoadAssetAsync(nameOfObjectToLoad);
Debug.Log("AssetLoadRequest : " + assetLoadRequest);
// I don't know what to do here !
myLoadedAssetBundle.assetBundle.Unload(false);
}}
↧
AssetBundle: how the files are ordered?
I'd like to implement a binary delta to update AssetBundles with a diff algorithm, but this would assume that the files should not change their relative positions.
Reading from [here (3.2)][1]:
> The header contains information about> the AssetBundle, such as its> identifier, compression type, and a> manifest. The manifest is a lookup> table keyed by an Object's name. Each> entry provides a byte index that> indicates where a given Object can be> found within the AssetBundle's data> segment. On most platforms, this> lookup table is implemented as a> balanced search tree. Specifically,> Windows and OSX-derived platforms> (including iOS) employ a red-black> tree. Therefore, the time needed to> construct the manifest will increase> more than linearly as the number of> Assets within an AssetBundle grows.
but it says nothing on the order the files are saved in the data segment. If they are saved in the order they are encoded in the lookup table, and if they are indexed by their GUID, or their hash, they should not change in position at least when not changed, but they are very big "if" that are not documented (or at least I was not able to find the relative documentation).
Write a delta algorithm that supports reordering whould be a lot more complex, so I'd avoid it if I can.
[1]: https://unity3d.com/learn/tutorials/topics/best-practices/assetbundle-fundamentals
↧
↧
How to remove inside of assetbundle camera in unity?
Hi, I need some help with the unity asset bundle. I changed my 3d object to Asset bundle but that bundle has a camera I loaded into unity take asset bundle camera only why.
↧
How to set static size all game object?
Hi, I need some help about asset bundle, I am imported asset bundle at runtime inside of unity but some asset bundle scale size different how to set static scale size. like imported asset bundle scale size is **X 10f, Y10f, Z10f** next am imported asset bundle scale size is **X 20f, Y 20f, Z 20f**, how to set static size please help Advance Thank You.
↧
Serializable Class On ScriptableObject Null when loaded from AssetBundle
For modularity reasons we build our game code to a dll. The assets are build to asset bundles from scene and we load these dynamically.
We're having a specific issue where instances of an editor-created (serialized) non-monobehaviour C# class are lost when building to dll. The instanced are however stored on a ScriptableObject which is available in our AssetBundle.
It seems like the instances that are defined in the inspector window and visible in the raw scriptableobject file are not being correctly instantiated in our dll build.
Running from within the editor while using dll scripts still works, but a standalone Windows build results in null references (the instances do not exist). The class itself does exist inside the dll build, because we can print a static string from it.
The ScriptableObject which stores the list of the SerializeAble Class (PathTile.cs)
[CreateAssetMenu(menuName = "KnuffelGame/KnuffelPath")]
public class KnuffelPath : ScriptableObject
{
[SerializeField]
private List tiles;
private float cleanedPercentage;
private bool isFinalPath;
public List Tiles
{
get
{
return tiles;
}
set
{
tiles = value;
}
}
}
The Serializable Class
[System.Serializable]
public class PathTile
{
[System.Serializable]
public enum Direction
{
Up,
Left,
Down,
Right
}
[SerializeField]
private Vector2 tileCords;
[SerializeField]
private Direction direction;
public Vector2 TileCords
{
get
{
return tileCords;
}
}
public Direction TileDirection
{
get
{
return direction;
}
}
}
And an image of where we create the PathTiles in the editor
![alt text][1]
Below is the saved ScriptableObject which has this list stored in text, this ScriptableObject is referenced in the scene and also available in the build, since we can debug it. This is the ScriptableObject that is visible in the image above.
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a4a21c2da3d5300449d25802ea791b03, type: 3}
m_Name: Path02
m_EditorClassIdentifier:
tiles:
- tileCords: {x: 1, y: 2}
direction: 3
- tileCords: {x: 1, y: 3}
direction: 3
- tileCords: {x: 1, y: 4}
direction: 3
- tileCords: {x: 2, y: 4}
direction: 2
- tileCords: {x: 3, y: 4}
direction: 2
- tileCords: {x: 4, y: 4}
direction: 2
- tileCords: {x: 4, y: 5}
direction: 3
- tileCords: {x: 4, y: 6}
direction: 3
- tileCords: {x: 4, y: 7}
direction: 3
- tileCords: {x: 4, y: 8}
direction: 0
- tileCords: {x: 3, y: 8}
direction: 0
But for some reason the list of Tiles does not get created, it ends up without items.
We tried building the scriptableobjects to a non-streamed AssetBundle and load these separately but faced the same problem.
[1]: /storage/temp/135448-scriptableobjectineditor.png
↧
How to build a single asset bundle?
Hello!
I know I can use BuildPipeline.BuildAssetBundles to build all the asset bundles in a unity project.
However, I would like to build just a single asset bundle.
BuildPipeline.BuildAssetBundles does have an overload that allows to specify which assets to build, but every attempt to use it always resulted in this error message:
Manifest AssetBundle name "testbundle" has conflict with the user predefined AssetBundle name.
I am unable to find any information about this error message and can't figure out what I did wrong.
Any help or info about this is appreciated!
↧
↧
Best approach for Asset Bundles.
I'm just looking for some feedback on what is the correct or best approace for using asset bundles to carry out a feature I need for an application.
I have a game where there is 5 or more levels on a tower and each level contains about 5 or so items (It can contain more or less) each Item can be clicked on and has information about it.
I need to have some way of downloading these assets on runtime to the application. The best approach I saw was the asset bundles. The items on each floor may change from time to time. For example there may be a crown asset and it could be modified or updated so I would need to swap it out for the newer version when the app is booted up.
I have an sqlite database which contains the item info, name, level it is located and the url to the asset bundle where it is stored. I think in the future I would also need an asset version field to keep track in the database of what version the asset is on then have a list stored locally on the device and cross referance it with the database versions to see if I need to redlownload the asset or not.
For now this is just a proof of concept so I will just redownload everybundle needed on the app launch. Then when each level loads each item will make a call to the asset bundle which will be stored in a singleton that will persist through each level. Each item will check each asset bundle for the appropriate model then instantiate it.
Does this seem like a logical way of going about things. I have never used asset bundles before and there seems to be alot of complexity to them especially with the addressable asset bundles which i'm trying to stay away from for now until I get a bit more experience with standard asset bundles.
↧
Do i need to make asset bundles with upgraded Unity version?
Hi All,
I am facing a difficult situation, need guidance in this. I have around 100 asset bundles uploaded which i am using in my app. I upgraded Unity to 2018.3. Now when i download asset bundle it turns black. Now, my question is should i Upload again all my asset bundles again? with unity 2018.3? Isn't this a bug time consuming task and on every update i should do all this again and again.
↧
Reloading Sprite Atlases from Asset Bundles
I'm having trouble reloading Sprite Atlases from Asset Bundles after they have already been loaded once.
I have a pretty heavy 2D game, with a lot of large sprites, so I would like to load them in and out of memory as you progress through different parts of the game. I'm trying to use Asset Bundles containing Sprite Atlases to achieve this, but I have a problem when I want to reload a Sprite Atlas that I had loaded previously.
Steps to reproduce my problem: 1. Subscribe to `SpriteAtlasManager.atlasRequested` for late binding of Sprite Atlases
2. When `atlasRequested` is called, load the requested a Sprite Atlas from an Asset Bundle. This works fine.
3. Now unload the Asset Bundle that was just loaded. The Sprite Atlas is unloaded with is and sprites disappear from the scene in Unity.
4. Now, how do I reload and rebind the Sprite Atlas? Can I somehow force the `SpriteAtlasManager` to call `atlasRequested` again?
Does this make sense? Is it the right strategy to solving my problem? Any thoughts?
**EDIT: I have had a look at this, which I think is doing what I want to do, but it seems like a pretty convoluted way to achieve something like this: https://github.com/jconstable/SpriteSleeper **
I have a pretty heavy 2D game, with a lot of large sprites, so I would like to load them in and out of memory as you progress through different parts of the game. I'm trying to use Asset Bundles containing Sprite Atlases to achieve this, but I have a problem when I want to reload a Sprite Atlas that I had loaded previously.
Steps to reproduce my problem: 1. Subscribe to `SpriteAtlasManager.atlasRequested` for late binding of Sprite Atlases
2. When `atlasRequested` is called, load the requested a Sprite Atlas from an Asset Bundle. This works fine.
3. Now unload the Asset Bundle that was just loaded. The Sprite Atlas is unloaded with is and sprites disappear from the scene in Unity.
4. Now, how do I reload and rebind the Sprite Atlas? Can I somehow force the `SpriteAtlasManager` to call `atlasRequested` again?
Does this make sense? Is it the right strategy to solving my problem? Any thoughts?
**EDIT: I have had a look at this, which I think is doing what I want to do, but it seems like a pretty convoluted way to achieve something like this: https://github.com/jconstable/SpriteSleeper **
↧
AssetBundle doesn't download on mobiles
Hello, I have this code for download an assetbundle from URL. In the editor works, the script downloads and opens the scene, but when I try it on iphone and android it doesn't download the assetbundle.
Can someone help me with this problem?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
using System.IO;
using UnityEngine.SceneManagement;
public class Descarga_Bundles_Script : MonoBehaviour
{
public string url;
public int downloaded = 0;
AssetBundle bundle;
public System.Object test;
public Slider progressbar;
public float progress;
WWW www;
void Update() {
progress = www.progress;
progressbar.value = progress;
}
IEnumerator Start() {
ClearCacheExample();
if (downloaded == 0) {
using (www = WWW.LoadFromCacheOrDownload(url, 0)) {
yield return www;
if (www.error != null)
throw new Exception("WWW download had an error:" + www.error);
if (www.error == null) {
bundle = www.assetBundle;
}
}
if (Caching.ready == true) {
downloaded = 1;
string[] scenePath = bundle.GetAllScenePaths();
Debug.Log(scenePath[0]);
SceneManager.LoadScene("Main_Menu");
}
}
}
void ClearCacheExample() {
Directory.CreateDirectory("Cache1");
Directory.CreateDirectory("Cache2");
Directory.CreateDirectory("Cache3");
Caching.AddCache("Cache1");
Caching.AddCache("Cache2");
Caching.AddCache("Cache3");
bool success = Caching.ClearCache();
if (!success) {
Debug.Log("Unable to clear cache");
}
}
}
↧
↧
Loading Sprites from AssetBundle produces disfigured images.
For a completely local project, I'm trying to use AssetBundles for improved asset management.
I imported some images, made sure they were defined as Sprites. I used the AssetBundle Browser to create an AssetBundle. Then I loaded the AssetBundle and read the files from the bundle.
I tried reading it as a Sprite or as a Texture2D. I tried compressing the bundle and non-compressed. It still comes out wierd.
Help?
![alt text][1]
[1]: https://scontent.fsdv3-1.fna.fbcdn.net/v/t1.0-9/49949393_2220179818005836_7650171730178080768_n.jpg?_nc_cat=109&_nc_ht=scontent.fsdv3-1.fna&oh=187dc5be19a565edfb5f44a1621c047f&oe=5CCDE82F
↧
Can i build assetbundle outside of project?
I am not familiar with English, so please excuse me.
I want automatically build assetbundle from google drive.
When i upload image resource to my google drive specific folder, my program will detect changes and build.
Thats i want.
But i can't find how to build assetbundle outside of project..
↧
Asset bundles missing asset data, and Unity does not report error during build.
We've recently started getting the following error while downloading asset bundles:> Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle [URL]
Fortunately, this is in development and has not been pushed to our live deployment.
We've spent a few days investigating and testing this issue, and it turns out that Unity is simply failing to write the asset data into the bundle. There is no error at build time, and the console output makes it look like Unity thinks everything is fine. It even reports the correct CRC for a valid bundle in the returned manifest file, even though the bundle is invalid.
This is happening to (seemingly) random bundles for Windows, Mac, iOS, and Android which are built on Windows or Mac.
We've implemented a post-build check into our build script which simply loads/unloads each bundle to validate them, but the only thing we can do at that point is rebuild and hope for the best.
We have not been able to find a repro case, but we do have console logs and bundles for good and bad bundles which should be identical.
This is a critical issue. A bad bundle on the CDN can be downloaded and cached, and it will require the file to be deleted from the cache to download a fixed file.
We are using Unity 2018.2.15f1.
↧