Keywords: Unity, Assets Loading, Resouces Extracting

Docs

AssetBundles
https://docs.unity3d.com/Manual/AssetBundlesIntro.html

Resources
https://docs.unity3d.com/ScriptReference/Resources.html

Tools & Libraries

TriLib - Model loader package
https://assetstore.unity.com/packages/tools/modeling/trilib-model-loader-package-91777

这里整合了Unity资源管理上的一些解决方案。包括资源统计,资源格式化,资源打包以及资源加载等等。
https://github.com/GameBuildingBlocks/UnityComponent

Examples

Extract textures and materials from FBX at run-time

Source:

public class ExtractMaterials : MonoBehaviour {

    // Use this for initialization
    void Start () {

        var materialsPath = "Assets/Materials";
        Directory.CreateDirectory(materialsPath);
     
        var texturesPath = "Assets/Textures";
        Directory.CreateDirectory(texturesPath);

        var assetsToReload = new HashSet<string>();
        foreach (string assetPath in AssetDatabase.GetAllAssetPaths())
        {
            if (assetPath.ToLower().Contains(".fbx"))
            {
                Debug.Log("Extracting for asset: " + assetPath);
                var importer = AssetImporter.GetAtPath(assetPath) as ModelImporter;

                var materials = AssetDatabase.LoadAllAssetsAtPath(importer.assetPath).Where(x => x.GetType() == typeof(Material));
                foreach (var material in materials)
                {
                    var newAssetPath = string.Join(Path.DirectorySeparatorChar.ToString(), new[] { materialsPath, material.name }) + ".mat";
                    var error = AssetDatabase.ExtractAsset(material, newAssetPath);
                    if (string.IsNullOrEmpty(error))
                    {
                        assetsToReload.Add(importer.assetPath);
                    }
                }
            }
        }
        foreach (var path in assetsToReload)
        {
            AssetDatabase.WriteImportSettingsIfDirty(path);
            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        }
    }
}

Origin:
https://forum.unity.com/threads/extract-textures-and-materials-from-fbx-at-run-time.532973/

Reference

Quoted
First you should know that Unity’s regular model pipeline is part of the editor, so it's not included in your runtime. You’re going to have to work around that fact. The easiest way is to import the model into Unity through the normal pipeline and get it all set up, then build it into an asset bundle, then host that asset bundle on the web. Then your runtime can just pull down the asset bundle from the web and load the resources from it. As I said, that's the easy way because you've got it all set up properly in Unity first and you can make sure the materials and textures and animations everything else get packed up with it in the asset bundle.

Is it possible to import 3D Model (FBX) assets into Unity App in runtime?
https://qr.ae/TqMdyP


The surest way to corrupt a youth is to instruct him to hold in higher esteem those who think alike than those who think differently. ― Friedrich Nietzsche