Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Ates Akaydin · May 25, 2010 at 03:43 PM · assetbundlestreamingstreambuildassetbundle

Unable to stream Assetbundles from web...

Hello There,

I have been trying to stream assetbundles from the Web Server which I own on one of my machines. The site is served by Apache Server application.

I have written the below two very basic script to serve this purpose:

using UnityEngine; using System.Collections; using System.Collections.Generic;

//Model pair structure which is used to store a single string/WWW instance struct ModelPair{ public string url; public WWW link; };

public class ModelLoader: MonoBehaviour {

 //Model Request Queue
 Queue<ModelPair> queue;

 //Models instantiated so far
 ArrayList models;

 //Awake Method
 void Awake(){
     queue = new Queue<ModelPair>();
     models = new ArrayList();
 }

 //Fixed Update
 void FixedUpdate(){

     if( queue.Count > 0 ){
         //1. Pick one item from the queue
         ModelPair item = queue.Dequeue();
         //Debug.Log( "Picked Item: " + item.url )
         //2. Check if a WWW is instantiated for item
         if( item.link != null ){
             //  2.1 If yes check whether if there exists an error in streaming the file
             if( item.link.error != null ){
                 //  2.1.1 If yes log an error message, pop the item and return  
                 Debug.Log( item.link.error );
                 return;
             }               
             //  2.2 Check whether the file is loaded
             if( item.link.isDone ){
                 //  2.2.1 If yes, instantiate the loaded model insert it to the models array. Pop the item and return   
                 GameObject model = (GameObject)Instantiate( item.link.assetBundle.mainAsset);                   
                 models.Add( model );

                 return;
             }
             else{
                 //  2.2.2 If no requeue the file at the end and return
                 queue.Enqueue( item );
             }
         }
         else{ 
             //3. If not create a new WWW instance for the item
             item.link = new WWW( item.url );
             queue.Enqueue( item );
             return;
         }
     }

 }

 //request a model at a particular url location to be loaded by the model loader
 //This function enqueues the request to the queue
 public void request( string url ){
     ModelPair newItem;
     newItem.url = url;
     newItem.link = null;
     queue.Enqueue( newItem );
 }   

}

I have a second script which uses this one and makes a model request as follows

using UnityEngine; using System.Collections;

public class SceneObjectStreamer : MonoBehaviour {

 //Model loader instance
 public ModelLoader modelLoader;

 //GUI
 public SceneGUI gui;


 // Use this for initialization
 void Start () {
     if( modelLoader != null ){
         modelLoader.request("file:///D:/projects/AssetBundleSerialization/assetbundles/athena.unity3d");        
     }
 }

}

The athena.unity3d is the assetbundle I have created correctly with my editor script. Anyway heres the problem. When I try to load this assetbundle from my file system it works correctly and the assetbundle pops up right away in the scene without problems.

However when I replace the URL with "http://www.mywebpage.com/athena.unity3d" I get an error which is:

Failed to load asset bundle UnityEngine.WWW:get_assetBundle() UnityEngine.WWW:get_assetBundle() ModelLoader:FixedUpdate() (at Assets\AssetBundleSerializationAssets\Scripts\Streaming\ModelLoader.cs:47)

Following this one I get a null pointer exception as the "mainAsset" field of the Assetbundle is null now. However this occurs within the "if" which controls whether if the download is finished. So if this is supposed to be a download error then shouldnt it be caught by the previous "if" which checks whether there was an error during streaming?

Can it be related to my Apache Server Configuration? Though I have uploaded my web player there as an html/unity3d file and I can access it on my browser without any problems. So I believe it is not the Apache Server which restricts access to those locations.

Anyone else had similar experience? Could you help?

Thanks a lot,

Ates Akaydin

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by Ates Akaydin · Jun 01, 2010 at 07:52 AM

Ok got it solved... Shame on me for asking this question without removing Apache basic login/password authorization.

Though I dont know still if I can bypass it via web form and sending it over via WWW instance before requesting the file.

IF anyone know of a secure way of transmitting files via WWW instance I would really appreciate that.

Best,

Ates

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

CharacterCustomization AssetBundles 1 Answer

Stream lots of AssetBundles at scene start smoothly... 1 Answer

Can AssetDatabase.LoadAllAssetsAtPath Load All Assets Recursively? 2 Answers

Alternative to BuildStreamedSceneAssetBundle ? 0 Answers

Build Assetbundles outside project? 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