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 vahid62 · Mar 07, 2016 at 01:44 PM · script.runtimeload

load c# script from server

Hi. I want download c# script from URL and load it in my game on runtime.

I know how to use www class to download script and store it in SD card. But how can I load this script to android game?

Thanks so much

Comment
Add comment · Show 1
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 meat5000 ♦ · Mar 07, 2016 at 03:16 PM 0
Share

What have you tried?

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Magius96 · Mar 07, 2016 at 03:33 PM

I don't know if what you are asking can actually be done because you don't have the compiler available at runtime for compiling and interpreting the script. Perhaps it would be better if you looked into including a scripting engine in your project so that you can use scripts instead of C#. That is, unless you intend to write a C# parser for your game.

Perhaps something like MoonSharp: https://www.nuget.org/packages/MoonSharp Or UniLua: https://github.com/xebecnan/UniLua

UniLua is designed specifically for Unity3D, where MoonSharp is designed for .NET and has proven compatible for Unity3D.

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 rushikesh988 · Mar 08, 2016 at 09:57 AM

Hi @vahid62,

You can't do that directly but you might want to look into assetbundles. You can include scripts into assetbundles.

Visit Here:

http://docs.unity3d.com/Manual/scriptsinassetbundles.html

QuickView:

If you want to include code in your AssetBundles that can be executed in your application it needs to be pre-compiled into an assembly and loaded using the Mono Reflection class (Note: Reflection is not available on platforms that use AOT compilation, such as iOS). You can create your assemblies in any normal C# IDE (e.g. Monodevelop, Visual Studio) or any text editor using the mono/.net compilers.Note: Loading scripts from asset bundles is not supported on Windows Store Apps and Windows Phone.

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 Silverfell · Mar 08, 2016 at 01:19 PM

Based on your other replies, you might want to look into loading and saving JSON objects that contain the details of all your objects.

By saving a JSON file that basically holds the catalog of your items, their preview pictures, 3d models and whatever else you need, you can then always just load it up in your game and download what you don't already have.

To be clear, the JSON could look something like this:

 [
   {
     'ID:1': {
       name: 'name',
       picture: 'here',
       model: 'it is here'
       },
         'ID:2': {
       name: 'name',
       picture: 'here',
       model: 'it is here'
       },
         'ID:3': {
       name: 'name',
       picture: 'here2',
       model: 'it is here'
       },
         'ID:4': {
       name: 'name',
       picture: 'here',
       model: 'it is here'
       }
   }
   ]

I am talking about JSON because Unity has a nifty new JSON serializer you can use. If you don't like JSON, you can save your data as XML, flat text, or even in a database. While everyone is perfectly correct in stating that you can't load C# files without a new build, you sure can download anything else you can get your hands on.

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
0

Answer by CptCheerios · Mar 07, 2016 at 03:37 PM

You can't load a script outside of the project. It needs to be compiled. What are you trying to accomplish, maybe there is a different way to accomplish it than this.

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 vahid62 · Mar 08, 2016 at 08:20 AM 0
Share

Thanks for replies. $$anonymous$$y project is a 3d catalog application. I have made many scenes and each scene has a 3d model ,animations and several scripts.

In the future i will want to add new models and scripts to this catalog and these assets all will be loaded from a server.

I don't want users have to be forced to download new version each time new model is added.

With assets bundle I can create each scene as a .unity3d file and upload it on server and load it in application and it works well but scripts are missing.

and yes the problem is script that must be compiled before in unity engine. so how can I do it?

avatar image unity_xrPBQ-2zcfd-DA vahid62 · Nov 26, 2018 at 06:32 AM 0
Share

Hey I am facing the similar kind of issue have you figured out a way to accomplish this?

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

42 People are following this question.

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

Related Questions

my textures aren't working (bmp files issue) 3 Answers

How to load a script at runtime? 0 Answers

load in Hierarchy 1 Answer

How can I programatically load a .pcx file in my script? 1 Answer

I think I abuse of Ressources.load 2 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