Skip to content

Commit 38fe41f

Browse files
committed
Initial commit
1 parent 34fb07e commit 38fe41f

File tree

9 files changed

+285
-0
lines changed

9 files changed

+285
-0
lines changed

.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
13+
# MemoryCaptures can get excessive in size.
14+
# They also could contain extremely sensitive data
15+
/[Mm]emoryCaptures/
16+
17+
# Recordings can get excessive in size
18+
/[Rr]ecordings/
19+
20+
# Uncomment this line if you wish to ignore the asset store tools plugin
21+
# /[Aa]ssets/AssetStoreTools*
22+
23+
# Autogenerated Jetbrains Rider plugin
24+
/[Aa]ssets/Plugins/Editor/JetBrains*
25+
26+
# Visual Studio cache directory
27+
.vs/
28+
29+
# Gradle cache directory
30+
.gradle/
31+
32+
# Autogenerated VS/MD/Consulo solution and project files
33+
ExportedObj/
34+
.consulo/
35+
*.csproj
36+
*.unityproj
37+
*.sln
38+
*.suo
39+
*.tmp
40+
*.user
41+
*.userprefs
42+
*.pidb
43+
*.booproj
44+
*.svd
45+
*.pdb
46+
*.mdb
47+
*.opendb
48+
*.VC.db
49+
50+
# Unity3D generated meta files
51+
*.pidb.meta
52+
*.pdb.meta
53+
*.mdb.meta
54+
55+
# Unity3D generated file on crash reports
56+
sysinfo.txt
57+
58+
# Builds
59+
*.apk
60+
*.aab
61+
*.unitypackage
62+
*.app
63+
64+
# Crashlytics generated file
65+
crashlytics-build.properties
66+
67+
# Packed Addressables
68+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
69+
70+
# Temporary auto-generated Android Assets
71+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
72+
/[Aa]ssets/[Ss]treamingAssets/aa/*

FbxMeshExtractor.Editor.asmdef

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "FbxMeshExtractor.Editor",
3+
"rootNamespace": "BYUtils.EditorTools",
4+
"references": [],
5+
"includePlatforms": [
6+
"Editor"
7+
],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [],
15+
"noEngineReferences": false
16+
}

FbxMeshExtractor.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FbxMeshExtractor.cs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using System.IO;
4+
5+
namespace BYUtils.EditorTools
6+
{
7+
public class FbxMeshExtractor : EditorWindow
8+
{
9+
private Object targetFbx;
10+
private string outputFolder = "Assets/ExtractedMeshes";
11+
12+
[MenuItem("Tools/BY Utils/FBX Mesh Extractor")]
13+
static void Init()
14+
{
15+
FbxMeshExtractor window = (FbxMeshExtractor)EditorWindow.GetWindow(typeof(FbxMeshExtractor));
16+
window.titleContent = new GUIContent("FBX Mesh Extractor");
17+
window.Show();
18+
}
19+
20+
void OnGUI()
21+
{
22+
GUILayout.Label("Extract All Meshes From FBX", EditorStyles.boldLabel);
23+
24+
targetFbx = EditorGUILayout.ObjectField("Target FBX", targetFbx, typeof(GameObject), false);
25+
outputFolder = EditorGUILayout.TextField("Output Folder", outputFolder);
26+
27+
if (GUILayout.Button("Browse Output Folder"))
28+
{
29+
string path = EditorUtility.SaveFolderPanel("Choose Output Folder", outputFolder, "");
30+
if (!string.IsNullOrEmpty(path))
31+
{
32+
// Convert to project relative path
33+
if (path.StartsWith(Application.dataPath))
34+
{
35+
outputFolder = "Assets" + path.Substring(Application.dataPath.Length);
36+
}
37+
else
38+
{
39+
Debug.LogWarning("Please select a folder within your project's Assets folder.");
40+
}
41+
}
42+
}
43+
44+
EditorGUILayout.Space();
45+
46+
GUI.enabled = targetFbx != null;
47+
if (GUILayout.Button("Extract All Meshes"))
48+
{
49+
ExtractMeshes();
50+
}
51+
GUI.enabled = true;
52+
}
53+
54+
void ExtractMeshes()
55+
{
56+
if (targetFbx == null) return;
57+
58+
// Ensure output folder exists
59+
if (!Directory.Exists(outputFolder))
60+
{
61+
Directory.CreateDirectory(outputFolder);
62+
}
63+
64+
GameObject fbxObject = targetFbx as GameObject;
65+
if (fbxObject == null)
66+
{
67+
EditorUtility.DisplayDialog("Error", "Selected object is not a valid GameObject/FBX file.", "OK");
68+
return;
69+
}
70+
71+
string fbxPath = AssetDatabase.GetAssetPath(fbxObject);
72+
if (string.IsNullOrEmpty(fbxPath))
73+
{
74+
EditorUtility.DisplayDialog("Error", "Could not determine asset path.", "OK");
75+
return;
76+
}
77+
78+
// Get all meshes
79+
Object[] assets = AssetDatabase.LoadAllAssetsAtPath(fbxPath);
80+
int extractedCount = 0;
81+
82+
foreach (Object asset in assets)
83+
{
84+
if (asset is Mesh)
85+
{
86+
Mesh mesh = asset as Mesh;
87+
string meshName = mesh.name;
88+
89+
// Create new mesh asset
90+
Mesh meshCopy = Object.Instantiate(mesh);
91+
meshCopy.name = meshName;
92+
93+
// Save to target folder
94+
string meshPath = Path.Combine(outputFolder, meshName + ".asset");
95+
AssetDatabase.CreateAsset(meshCopy, meshPath);
96+
extractedCount++;
97+
}
98+
}
99+
100+
AssetDatabase.SaveAssets();
101+
AssetDatabase.Refresh();
102+
103+
EditorUtility.DisplayDialog("Extraction Complete",
104+
$"Successfully extracted {extractedCount} meshes to {outputFolder}.", "OK");
105+
}
106+
}
107+
}

FbxMeshExtractor.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 BarryY
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

LICENSE.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# FBX Mesh Extractor for Unity
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
5+
## Overview
6+
7+
FBX Mesh Extractor is a Unity editor extension tool that allows you to quickly extract all mesh assets from FBX files and save them as independent asset files. This tool is particularly useful for developers who need to access and manipulate model meshes individually.
8+
9+
## Features
10+
11+
- Extract all mesh assets from any FBX file
12+
- Simple editor interface operation
13+
- Customizable output folder location
14+
- Automatic creation of missing folders
15+
- Batch extraction and saving of all meshes
16+
17+
## Installation
18+
19+
### Option 1: Using Unity Package
20+
21+
1. Download the latest Unity Package release
22+
2. In Unity Editor, go to Assets > Import Package > Custom Package
23+
3. Select the downloaded package file
24+
4. Make sure all files are selected and click Import
25+
26+
### Option 2: Manual Installation
27+
28+
1. Clone or download this repository
29+
2. Copy the `FbxMeshExtractor.cs` file to the `Assets/Editor` folder in your Unity project
30+
(create the Editor folder if it doesn't exist)
31+
32+
## Usage
33+
34+
1. In Unity Editor, go to Tools > BY Utils > FBX Mesh Extractor
35+
2. In the popup editor window, drag and drop your target FBX file to the Target FBX field
36+
3. (Optional) Set the output folder path or use the browse button to select it
37+
4. Click the "Extract All Meshes" button
38+
5. All mesh assets will be extracted and saved to the specified output folder
39+
40+
## License
41+
42+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
43+
44+
## Contributing
45+
46+
Issues and pull requests are welcome. Your contributions will help make this tool better!

README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)