Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Elcolmo · May 13, 2016 at 09:31 AM · textureprefabassetbundleserverpink

Loading prefab from Server as AssetBundle, NO material/texture loading (PINK result)

My question is, I am trying to load an AssetBundle of a prefab I created, from my server. In the server I have the next folder distribution:

public_http/Assets/
AssetBundles(Here I have all my AssetBundles prefab, material, textures)
cube_example (Here I have my real prefab, texture, material and gameobject)

I am using the next code to create my AssetBundles:

 using UnityEditor;

 public class CreateAssetBundles
 {
      [MenuItem("Assets/Build AssetBundles")]
      static void BuildAllAssetBundles()
      {
          BuildPipeline.BuildAssetBundles("Assets/AssetBundles");
     }
 }

And I am using this script to load my Assets:

 using System;
 using UnityEngine;
 using System.Collections;

 public class CachingLoadExample : MonoBehaviour
 {
     public string BundleURL; // --> http://Myserver/public_http/Assets/AssetBundles/cube_prefab (path to the AssetBundle)
     public string AssetName; // --> Cube_pref (name of the Asset prefab)
     public int version;

     void Start()
     {
         StartCoroutine(DownloadAndCache());
     }

     IEnumerator DownloadAndCache()
     {
     // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
         using (WWW www = WWW.LoadFromCacheOrDownload(BundleURL, version))
         {
             yield return www;
             if (www.error != null)
                 throw new Exception("WWW download had an error:" + www.error);
             AssetBundle bundle = www.assetBundle;
             if (AssetName == "")
                 Instantiate(bundle.mainAsset);
             else
             {
                 GameObject gameObject = bundle.LoadAsset(AssetName) as GameObject;
                Instantiate(bundle.LoadAsset(AssetName));

            }
             // Unload the AssetBundles compressed contents to conserve memory
             bundle.Unload(false);

         } // memory is freed from the web stream (www.Dispose() gets called implicitly)
     }
 }

The result is I obtain my prefab without any material/texture (PINK colored cube) allthough in the AssetBundle manifests I can see it has linked the dependecies. I really don't know what's happening. I don't know if I am construction the AssetBundle in a mistaken way or if I am trying to load the prefab in the wrong way.

Any help would be perfect.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image incorrect · May 13, 2016 at 09:31 AM 0
Share

Are textures and materials included in bundle?

avatar image Elcolmo incorrect · May 13, 2016 at 09:34 AM 0
Share

I really don't know. How would you include them in the bundle?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Elcolmo · May 13, 2016 at 11:13 AM

I have solved my problem. My error was to create AssetBundles of each prefab, material and texture. Know I have created a unique AssetBundle of the hole folder and I am calling the prefab. The result is the prefab with a texture on it.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ngoson107 · Mar 02, 2018 at 10:23 AM 0
Share

Thank you for your reply. I have a question: How to create a unique AssetBundle of the hole folder. Thank you so much !

avatar image Bunny83 ngoson107 · Mar 02, 2018 at 12:06 PM 0
Share

Just check the manual

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A texture/material loading problem in Unity 4 iPhone 0 Answers

Is there an option to pack textures using AssetBundles using Unity's image compression? 1 Answer

Use assets from another project? 1 Answer

Prefab material 1 Answer

Texture on instantiated asset bundle sometimes black only on iPhone 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges