- Home /
Download and IMPORT .obj to Android
hi @AgentMilkshake1 ,
Can you help me about downloading and importing .obj file in android device and show the my scene run time ?
Dear Sir,
I'm in the same trouble, I can import it on runtime from the laptop but unable to import it in my Android. Have you been able to solve it?
Answer by AgentMilkshake1 · Feb 23, 2019 at 12:40 PM
Hey there
It was a long time ago so lets see if I can remember! Also if it's cool I'd rather explain on here rather than via email, hopefully the many others following this question will be able to benefit from the answer.
I think I downloaded a suitable runtime obj importer, after a quick google there is a free Runtime OBJ Importer (https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547) This wasn't the one I used but it looks suitable due to the fact it works during runtime and not just in editor. EDIT:Turns out this was the one I used!
As for the download part, I believe I used webcalls (potentially via CURL) to download the OBJ from the source URL (determined via a URL in a JSON file that was again gained via a webcall to the server service I was working with.
When you download the file, you should know where the file was saved, this way you should then be able to specify the file location to the OBJ importer. You can then follow the documentation with your selected runtime OBJ importer to load it into your scene.
I hope that was somewhat useful - as I said, it's been a very long time (about 15 months) since I first implemented this, and I don't have the project available to check the exact details. However, the above steps should be fairly easy to replicate using Google to help you find out how to make web calls in Unity, find a suitable Runtime OBJ Importer, and then load it from the downloaded file.
All the best
Also, check out this old comment of $$anonymous$$e for downloading across various platforms...
Hi @Agent$$anonymous$$ilkshake1 ,
I downloaded my object , thank you so much :) so how can i show the model on scene ?
@cagdas01 Brilliant!
Can you delete your other reply to the question so we can contain the answer here (sounds like you were having some difficulties but got around it?).
Now you've downloaded your object, you should have a reference to the object path? You should be able to feed that object path into the Runtime OBJ Importer function "LoadOBJFile" which will spit out a Gameobject for you!
Ok , I deleted my other comment. Now , When I drag my object in Assets , I can instantiate the object on scene using the path :"GameObject myObj = (GameObject)Instantiate(Resources.Load("Prefeb/obj")); But When I download the object the path:C:\Users\Cagdas\AppData\LocalLow\Teknik$$anonymous$$edya\CopyComponent\Assets\Resources\Prefeb (it means Application.persistentDataPath+"/Assets/Resources/Prefeb/obj" , same way I make GameObject bull = (GameObject)Instantiate(Resources.Load(Application.persistentDataPath+"/Assets/Resources/Prefeb/obj")); but I take the error " ArgumentException: The Object you want to instantiate is null. UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:383) UnityEngine.Object.Instantiate (UnityEngine.Object original) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:240) $$anonymous$$ilkShake.LoadObj () (at Assets/scene2Script/$$anonymous$$ilkShake.cs:58) UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:166) UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58) UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:66) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:108) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261) UnityEngine.EventSystems.EventSystem:Update()"