Unity dynamically creates a storage path for FBX model configuration files

Source: Internet
Author: User

Create the pre-directory structure:

The directory structure after creation:

usingSystem.Collections;usingSystem.Collections.Generic;usingUnityengine;usingUnityeditor;usingSystem.IO;usingSystem.Text; Public classbuildtool{[MenuItem ("Buildtool/refreshcloth/refreshselectclothconfig")]    Static voidRefreshselectcloth () {stringConfigrootpath ="Assets/clothconfig"; foreach(Unityengine.object oinchSelection.getfiltered (typeof(Gameobject), selectionmode.deepassets)) {            //ASSETS/FBX/CHARACTER/MODELS/G_CLOTH_50133/G_CLOTH_50133.FBX            stringClothpath =Assetdatabase.getassetpath (o); //get the name of the model configuration, as in the example: g_cloth_50133            intSubstart = Clothpath.lastindexof ('/') +1; intSublenth = Clothpath.lastindexof ('.') -Substart; stringClothconfigname =clothpath.substring (Substart, sublenth); //get the storage path for the model configuration, as in the example: assets/zlgstest/clothconfig/g_cloth_50133//Note that the path is stored instead of the file            stringClothconfigpath = Configrootpath +"/"+Clothconfigname; //if the above path does not exist, go to create a            if(!directory.exists (Clothconfigpath))        Directory.CreateDirectory (Clothconfigpath);    } Assetdatabase.refresh (); }}

It is important to note that you must first select a model resource before you create it!!!

Unity dynamically creates a storage path for FBX model configuration files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.