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 Spatiulus · Jul 29, 2012 at 02:30 AM · webplayerassetbundledatapath

WebPlayer dataPath

Hello! I want to load an assetBundle from the server to economy the loading time. I searched a huge variety of topics and finally I read that the best method to load assetBundles is using the Application.dataPath (read it here).

First I create a Bundle, using BuildPipeline.BuildAssetBundle from documentaion (here). Then I used this code to load it:

 function Start () {
 
     var www = new WWW("file://" + Application.dataPath + "/myBundle.unity3d");
 
     Instantiate(www.assetBundle.mainAsset);
 
 }

Worked fine for editor (my bundle was in the Assets folder) and also worked in .exe, when I changed the code like this: "file://" + Application.dataPath + "/../myBundle.unity3d (my bundle was in the same directory, as the .exe file)

But nothing works in WebPlayer! I feel it should be very simple, but I really can't understand what to change. Help me please, sure that this question is interesting for many people.

Thank you very much!

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

2 Replies

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

Answer by Spatiulus · Jul 29, 2012 at 11:11 AM

THE PROBLEM IS SOLVED! I added a GUI text, which shows the log to watch it in WebPlayer. So he wrote me, that the WebPlayer just didn't had time to download my bundle on function Start! The action should be repeated, until the download is over. Through my ignorance, I missed yield www, from the assetBundle documentation. Just because didn't knew it's meaning. Hope this experience will help somebody like me. :)

Here is my working code (a little modified):

var assetPath;

function Start () {

if (Application.isEditor) {

assetPath = "file://" + Application.dataPath + "/Bundle.unity3d";

}

else {

assetPath = Application.dataPath + "/Bundle.unity3d";

}

www = new WWW(assetPath);

yield www; // HERE YOU ARE!

Instantiate(www.assetBundle.mainAsset);

}

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
avatar image
1

Answer by earth5 · Jul 29, 2012 at 11:10 AM

As I understand it, Web Player can't use Application attributes/functions/etc. They need to be stored on a remote server and accessed via http:// instead. This was driving me nuts too.

Comment
Add comment · Show 3 · 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 Spatiulus · Jul 29, 2012 at 11:14 AM 0
Share

Thanks for answering, but I solved the problem! The solution is moderating now, and should be published here soon! :)

avatar image Spatiulus · Jul 29, 2012 at 11:16 AM 0
Share

(It was published higher :)

avatar image fablelabs · Sep 09, 2013 at 04:52 PM 0
Share

According to Unity Script Reference http://docs.unity3d.com/Documentation/ScriptReference/Application-dataPath.html Application.dataPath does exist for Web Player, and it points to the URL to the player data file folder

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

7 People are following this question.

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

Related Questions

Android StreamingAssets File Access 6 Answers

how can i create assetbundle .unity3d file? 0 Answers

How to load Assets as GameObjects? 1 Answer

AssetBundle.CreateFromMemory fails in WebPlayer 1 Answer

AssetBundle not loaded in webplayer after refreshing page 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