Unity - Loading .obj files from an external source during runtime? - unity3d

Is it in any way possible to load objects that are not within the project itself during runtime in a Unity project? Importing from an assets bundle is not what I'm looking for.

For that you need to import an asset from the Unity assets store to do the importing job for you.
There are free ones, like the Runtime OBJ Importer.
Experiment with different ones and see what suits you most!
Good luck :)

Related

How do I export a steam game into a unity package

I've been wanting to mod hollow knight for a while now and since I have recently gained experience with the unity game engine I thought I would try it out. The only problem is I can't really find a way to export the files into unity and so far have found no tutorials online maybe exporting it into a package is not the answer so I'm just curious on how to import the files into unity.
That's not really how game modding works. You won't be able to import the compiled game's assets into Unity. If the game uses the Mono runtime (not IL2CPP), you can find the DLL files that contain the game's logic, decompile them (using a decompiler like dotPeek), make modifications to the game's source code (for example, adding your own logic to change behavior and load additional assets), recompile the code, and replace the game's original DLLs with your modified version.

How to get a file out of a compiled unity game that I made

I created a mini game using Unity and built it a few months back. It was just a pet project so I deleted the project file but still have the built/compiled game. In the project's ASSETS, I put a text file with some notes that I had created for myself and some scripts.
Is there a way to extract or even just see the text file from my built game? Is there a way to extract all the assets or something?
I'm extremely new at this kind of thing so unfortunately, I don't really know the right way to ask the question or find it on google. Any help would be appreciated.
Thank you.
Probably not
That text file, if it wasn't used as an asset, isn't going to be in your compiled game anyway. But even if it was, finding it and extracting it would be difficult due to the semi-obfuscated nature of dlls and how Unity compresses and builds assets into dlls.
If you want to make the file accessible post-build by design, use StreamingAssets folder.
Otherwise you'll have to rely on 'uglier' methods as mentioned by Draco18s (people steal assets all the time so it's not impossible).
what's your building platform ?
if it's android then you can get a look at the scripts and other text files using ILSpy.
Just change the .apk to .zip
Unzip, and open the compiled files in ILSPY.

A lot of 3D model file can freeze Unity editor and Jetbrains Rider

I would like to use a lot of 3D models more than 4000.
The folder can be at least 20GB size.
When I opened this folder with Unity editor, it freeze my Unity engine and Jetbrains Rider as you thought. However, these models is no reason to be loaded in every time since several models being loaded is determined in dynamic on runtime.
I think I can make use of AssetBundle feature to load these model in dynamic. However, I think that limit assets must be placed in Assets folder to build as asset. That can freeze my editor and Rider.
But technically, I think AssetBundle must be able to be build in separately.
How can I solve this problem?
You can indeed use Assetbundles to fix this issue. If you have all your models build into assetbundles you can store the assetbundle file and assetbundle.manifest on a remote server or FTP and just download it at runtime whenever you need the asset. this way the models will never be in your build project and can even be in a seperate unity project, solving your crashing issues on your main project.
For my answer i'll be assuming you are using Unity's new Assetbundle browser tool and using a Unity version that is higher than 5.6. If you do not have the new Assetbundle browser here are some quick steps to get it:
Download the AssetBundle Browser tool from Unity's GitHub
Add the downloaded files to your Unity project's /Asset/ folder
Go to Window > assetbundle browser
a quick tutorial can be found here
Building the bundles
The benefit of using assetbundles for this is that, as long as the Unity versions match, they can be build from seperate projects. Therefore i would recommend creating a new empty project and testing how many models you can have in that project without crashing Unity.
Once you have found that limit create prefabs out of the models, and add them to the Assetbundle browser tool.
Set the target platform for which you want to build the assetbundles and the compression you want to apply to in the "build" secton of the assetbundle browser tool. once you have done that hit "build" to build your assetbundles.
Once this process is completed you can take the assetbundle file and assetbundle.manifest and upload them to a seperate server or FTP that the client can connect to at runtime to download the required assetbundle, containing the desired model.
Since the new Assetbundle browser tool is open source you can also automate the process of uploading the assetbundles directly after they have been build.
another benefit of this is that the assetbundle browser will detect any shared assets (e.g shaders, scripts) and give you the option you move them into a shared assetbundle that only needs to be downloaded once, and any following assetbundle can call. This way you won't have to keep downloading shared assets.
Building assetbundles is quite a time consuming task (also depending on the target platform and compression settings) so if you have the resources available you might want to do this on multiple computers at once.
You may try to exclude folder from being indexed.
https://youtrack.jetbrains.com/issue/RIDER-8664#comment=27-2399808
I think the best way to fix it is simply not using so many models.
So simple.
You should choose models that will fit best for the rest and just create few diffrent texture for each model.
Its like in the movies. You dont need 2000 ppl to make crowd. You just need 20 different ppl and copy paste there in CGI.

Creating Unity Asset bundles at runtime

I have a windows application which users can import fbx models into. What I want to do is to be able to create asset bundle from these imported fbx models and then save the bundle file to a server. I wanted to ask if such thing is possible with unity. I have searched for answers but couldn't find any , there were some similar threads but none was exactly addressing this.
I'll appreciate if someone can help me with this.
Thanks

Unity - Is it necessary to exclude assets being used in AssetBundles from game build?

Having a difficult time finding much information on how AssetBundles actually work. Can't find any explanation on how to manage asset bundles with a game build.
Basically I have a folder called AssetBundles in my Project window. All assets that I put in this folder are built as AssetBundles in a folder within my build directory (like GameName/Data/AssetBundles) which are then loaded when needed.
But when I build the game itself, does it know not to include these assets that are being used in AssetBundles in the game build? Or do I need to exclude them in some way?
Edit: I've made some progress.
To my understanding, only assets of which reside in scenes that are in the build settings will be built with the game build. Scripts are always built in the game build (I'm not sure if there's a way of getting around this but it's not an issue to me).
So I have a single scene which is in the game build which acts as the startup object of the game. This scene has an Asset Manager script on it with DontDestroyOnLoad specified in Awake.
My asset manager script basically just handles loading/unloading of bundles, assets and instances.
I'm currently not too sure about how building asset bundles for scenes work. I have it working using LoadAllAssets and then doing LoadLevel, but what if multiple scenes share some assets? Do scene builds end up bloated having copies of assets that can be shared? I read that dependencies are automatically handled in Unity 5, but I'm not sure if that relates to this.
I found the below post which has a sample project with different ways of using AssetBundles in Unity 5.
http://forum.unity3d.com/threads/new-assetbundle-build-system-in-unity-5-0.293975/
It includes an example of building/loading scenes and it seems to work correctly (it automatically determines dependencies.. so all you have to do is ensure you build shared assets in a shared asset bundle (or their own bundle) for efficiency).
The only thing I was doing differently on the build is defining AssetBundleBuild (basically I organized my project folder so that assets are stored in subfolders which correlate to their assetbundle names, and then on build it checks these folders and adds them).
For some reason my method of doing that seems to break dependencies whereas using the asset bundle feature in the editor ui seems to work (manually naming the bundle for every asset.. which is a bit tedious if you have hundreds of assets in several different bundles) and then using BuildAssetBundles without the builds argument.
I still don't really have an answer to my original question Is it necessary to exclude assets being used in AssetBundles from game build?
But to be safe, I only have 1 scene actually being built in the game build, and that scene just has an asset manager script on which handles asset bundles and it doesn't destroy on load. No need to have other scenes being built if you have them all as asset bundles.
When you build the game it should only use the assets that are in the build as in anything that you use or is a dependency of anything used in the build.