zoukankan      html  css  js  c++  java
  • Unity动态创建FBX模型配置文件的存放路径

    创建前目录结构:

    创建后的目录结构:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEditor;
    using System.IO;
    using System.Text;
    
    public class BuildTool
    {
        [MenuItem("BuildTool/RefreshCloth/RefreshSelectClothConfig")]
        static void RefreshSelectCloth()
        {
            string configRootPath = "Assets/AssetData/ClothConfig";
            foreach (UnityEngine.Object o in Selection.GetFiltered(typeof(GameObject), SelectionMode.DeepAssets))
            {
                //Assets/FBX/Character/Models/g_Cloth_50133/g_Cloth_50133.FBX
                string clothPath = AssetDatabase.GetAssetPath(o);
    
                //获得模型配置的名字,例子中即: g_Cloth_50133
                int subStart = clothPath.LastIndexOf('/') + 1;
                int subLenth = clothPath.LastIndexOf('.') - subStart;
                string clothConfigName = clothPath.Substring(subStart, subLenth);
    
                //获得模型配置的存放路径,例子中即: Assets/ZLgsTest/ClothConfig/g_Cloth_50133
                //注意是存放路径,而不是文件
                string clothConfigPath = configRootPath + "/" + clothConfigName;
    
                //如果以上路径不存在,则去创建一个
                if (!Directory.Exists(clothConfigPath))
                    Directory.CreateDirectory(clothConfigPath);
            }
    
            AssetDatabase.Refresh();
        }
    }

    需要注意的是,在创建之前一定要先选中一个 模型资源!!!

  • 相关阅读:
    JDBC学习笔记
    hdfs文件格式
    全国疫情防控监控平台开发
    MySQL学习笔记
    拖拽表单生成
    Cython加密(含Windows和Linux)
    pcl 文字点云
    新装Ubuntu系统--常用软件安装配置
    GIT
    Data Analysis With Python
  • 原文地址:https://www.cnblogs.com/luguoshuai/p/9148153.html
Copyright © 2011-2022 走看看