黑彩网站建设运营,wordpress cms模板,seo建站系统,定制商品的网站建设最近在做动态加载读取外部模型的功能使用了triLib插件#xff0c;废话不多说直接干货。 第一步下载导入插件#xff0c;直接分享主打白嫖共享#xff0c;不搞花里胡哨的。 链接#xff1a;https://pan.baidu.com/s/1DK474wSrIZ0R6i0EBh5V8A 提取码#xff1a;tado 导入后第…最近在做动态加载读取外部模型的功能使用了triLib插件废话不多说直接干货。 第一步下载导入插件直接分享主打白嫖共享不搞花里胡哨的。 链接https://pan.baidu.com/s/1DK474wSrIZ0R6i0EBh5V8A 提取码tado 导入后第一步新建一个管理渲染管线的文件 第二步建立一个渲染管线的文件放入上一个创建的文件中 配置完成后新建一个文件夹需要把文件和贴图放在同一文件夹内 注意添加后缀名称
然后抄一下demo代码 有兴趣的可以去研究demo 我是为了快速实现就不细讲了
using System.Collections;
using System.Collections.Generic;
using TriLibCore;
using UnityEngine;
using System.IO;public class GetLoadFbx : MonoBehaviour
{//文件路径要加载的模型的绝对路径不能为空string modelFilename;[Header(模型贴图必须在同级目录会自动读取原始模型的使用贴图)]//文件名称public string name;public SetUV GetSetUV;//这个可以忽略public AssetLoaderOptions options;//这个就是你创建管理渲染的物体void Start(){GetSetUVGetComponentSetUV();modelFilename Application.dataPath /GetModel/Model/SAST5000/;LoadNameModel(name);}void LoadNameModel(string name){modelFilename name;AssetLoader.LoadModelFromFile(modelFilename, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, options); }/// summary/// Called when any error occurs./// /summary/// param nameobjThe contextualized error, containing the original exception and the context passed to the method where the error was thrown./paramprivate void OnError(IContextualizedError obj){Debug.LogError($An error occurred while loading your Model: {obj.GetInnerException()}); //加载模型时发生错误}/// summary/// Called when the Model loading progress changes./// /summary/// param nameassetLoaderContextThe context used to load the Model./param/// param nameprogressThe loading progress./paramprivate void OnProgress(AssetLoaderContext assetLoaderContext, float progress){Debug.Log($Loading Model. Progress: {progress:P});}/// summary/// Called when the Model (including Textures and Materials) has been fully loaded./// /summary/// remarksThe loaded GameObject is available on the assetLoaderContext.RootGameObject field./remarks/// param nameassetLoaderContextThe context used to load the Model./param材料加载。模型完全加载private void OnMaterialsLoad(AssetLoaderContext assetLoaderContext){}/// summary/// Called when the Model Meshes and hierarchy are loaded./// /summary/// remarksThe loaded GameObject is available on the assetLoaderContext.RootGameObject field./remarks/// param nameassetLoaderContextThe context used to load the Model./param模型加载。装材料private void OnLoad(AssetLoaderContext assetLoaderContext){Debug.Log(Model loaded. Loading materials.);}void Update() {}}