blob: a4e81b1b6258aa8a387834f01377320e63bd43df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.IO;
public class MainFbx : MonoBehaviour
{
public GameObject fbx;
public static void _MakeMainFbx(GameObject fbx)
{
string fbxPath = AssetDatabase.GetAssetPath(fbx).ToLower();
if(fbxPath.EndsWith("_bandpose.fbx"))
{
int index = fbxPath.LastIndexOf("/");
if (index >= 0)
{
string dir = fbxPath.Substring(0, index);
index = dir.LastIndexOf("/");
if (index >= 0)
{
string dirname = dir.Substring(index + 1);
GameObject mainFbx = new GameObject(dirname);
MainFbx mf = mainFbx.AddComponent<MainFbx>();
mf.fbx = fbx;
string prefabPath = dir + "/" + dirname + ".prefab";
XEditor.AssetModify.CreateOrReplacePrefab(mainFbx, prefabPath);
GameObject.DestroyImmediate(mainFbx);
}
}
}
}
[MenuItem(@"Assets/Tool/Fbx/MakeMainFbx")]
public static void MakeMainFbx()
{
GameObject[] fbxs = Selection.gameObjects;
if (fbxs.Length == 1)
{
_MakeMainFbx(fbxs[0]);
}
}
[MenuItem(@"Assets/Tool/Fbx/RefreshMainFbx")]
private static void RefreshMainFbx()
{
DirectoryInfo di = new DirectoryInfo("Assets/Creatures");
DirectoryInfo[] subDirs = di.GetDirectories("*.*", SearchOption.TopDirectoryOnly);
foreach (DirectoryInfo subDir in subDirs)
{
FileInfo[] files = subDir.GetFiles("*_bandpose.fbx", SearchOption.TopDirectoryOnly);
if (files.Length == 1)
{
string path = files[0].FullName.Replace("\\", "/");
int index = path.IndexOf("Assets/Creatures");
path = path.Substring(index);
GameObject fbx = AssetDatabase.LoadAssetAtPath<GameObject>(path);
_MakeMainFbx(fbx);
}
}
AssetDatabase.Refresh();
}
}
#endif
|