- Home /
[Android] Download file.cs from Url & use it instead of original script.
Hi ^^
For Android application, wanted to apply downloadedFile.cs downloaded from Url instead of defaut script.
My script (DOESN'T WORK) :
public void NouvellesAnnonces (){
WWW ww = new WWW("http://myWebSite/Ajouter.cs");
StartCoroutine (NouvellesAnnoncesCor(ww));
}
IEnumerator NouvellesAnnoncesCor(WWW ww){
yield return ww;
#if UNITY_ANDROID //DOESN'T WORK
StreamWriter writer = new StreamWriter ("Assets/Scripts/AnnonceCherche.cs");
writer.WriteLine (ww.text);
writer.Close ();
#endif
}
Answer by Naphier · Oct 18, 2016 at 07:17 AM
Scripts must be compiled for them to work in the application. They cannot be added at runtime.
Is there a solution to read downloaded file as lines code ? [Android app]
Actually, it is possible to dynamically compile during runtime, but it's not easy: https://community.unity.com/t5/Scripting/Compiling-C-at-runtime/td-p/2493879
Thank you Tanoshimi, but I am french, that solution will be very hard to understand & apply it correctly.
That's pretty neat. Actually doesn't look that hard, but it seems like a bad design choice and not really worth the effort. What are you trying to achieve here?
I would like to update informations from my server via downloadedFile.cs. The content of downloadedFile.cs to be execute directly in the script compiled. Example of content of downloadedFile.cs :
StartCoroutine (PartiChiensChatsCor (0, "http://www.chatterieofmagicarcadia.fr/docs/infos/cream.jpg", "978494654654654", "20:14", "24 septembre 2016", "$$anonymous$$inou", "LOF / LOOF", "$$anonymous$$aine Coon", "Gourmand", "3", "Adulte", "$$anonymous$$âle", "Grand", "Oui", "Tatoué", "654987321654", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. $$anonymous$$aecenas sed tortor feugiat, sagittis ligula id, sollicitudin nulla. Nunc feugiat lectus vitae pulvinar fermentum. Praesent sed efficitur nulla. Nullam sapien arcu, bibendum in quam in posuere.", "1200", "Concepteur", "16000", "Paris", "000000000", "examplemail@gmail.com"));
Example of script in the Android app :
public void NouvellesAnnonces (){
StartCoroutine ("NouvellesAnnoncesCor");
}
IEnumerator NouvellesAnnoncesCor(){
WWW w = new WWW("http://myWebSite/downloadedFile.cs");
yield return w;
//use the content of downloadedFile.cs like lines code
w.text;
}
Your answer

Follow this Question
Related Questions
insert my folder into an apk 0 Answers
Error occurs when trying to delete file in DCIM on Android 0 Answers
Wait for file download 1 Answer
WWW file download size 0 Answers