Skip to content

Commit 0217c59

Browse files
committed
code review fixes
1 parent e640d75 commit 0217c59

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static GameObject Convert (
144144
fbxFullPath = IncrementFileName (fbxDirectoryFullPath, fbxFullPath);
145145
}
146146
}
147-
var projectRelativePath = GetAssetRelativePath (fbxFullPath);
147+
var projectRelativePath = EditorTools.ExportSettings.GetProjectRelativePath (fbxFullPath);
148148

149149
// Make sure that the object names in the hierarchy are unique.
150150
// The import back in to Unity would do this automatically but
@@ -184,24 +184,14 @@ public static GameObject Convert (
184184
prefabFullPath = IncrementFileName (prefabDirectoryFullPath, prefabFullPath);
185185
}
186186
}
187-
var prefabProjectRelativePath = GetAssetRelativePath (prefabFullPath);
187+
var prefabProjectRelativePath = EditorTools.ExportSettings.GetProjectRelativePath (prefabFullPath);
188188

189189
SetupFbxPrefab (toConvert, unityMainAsset, prefabProjectRelativePath, fbxFullPath);
190190

191191
toConvert.name = Path.GetFileNameWithoutExtension (fbxFullPath);
192192
return toConvert;
193193
}
194194

195-
private static string GetAssetRelativePath(string fullPath){
196-
var assetRelativePath = FbxExporters.EditorTools.ExportSettings.ConvertToAssetRelativePath(fullPath);
197-
var projectRelativePath = "Assets/" + assetRelativePath;
198-
if (string.IsNullOrEmpty(assetRelativePath)) {
199-
throw new System.Exception("Path " + fullPath + " must be in the Assets folder.");
200-
}
201-
return projectRelativePath;
202-
}
203-
204-
205195
/// <summary>
206196
/// Create the prefab and connect it to the given fbx asset.
207197
/// </summary>

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@ public class ConvertToPrefabEditorWindow : ExportOptionsEditorWindow
1515
private GameObject[] m_toConvert;
1616
private string m_prefabFileName = "";
1717

18-
public static void Init (GameObject[] toConvert)
18+
public static void Init (IEnumerable<GameObject> toConvert)
1919
{
2020
ConvertToPrefabEditorWindow window = CreateWindow<ConvertToPrefabEditorWindow> ();
21-
window.InitializeWindow (filename: toConvert.Length >= 1? toConvert[0].name : "", singleHierarchyExport: true, exportType: ModelExporter.AnimationExportType.all);
21+
window.InitializeWindow (filename: "", singleHierarchyExport: true, exportType: ModelExporter.AnimationExportType.all);
2222
window.SetGameObjectsToConvert (toConvert);
2323
window.Show ();
2424
}
2525

26-
public void SetGameObjectsToConvert(GameObject[] toConvert){
27-
m_toConvert = toConvert;
28-
if (toConvert.Length >= 1) {
29-
m_prefabFileName = toConvert [0].name;
26+
protected void SetGameObjectsToConvert(IEnumerable<GameObject> toConvert){
27+
var tempList = new List<GameObject> ();
28+
foreach (var go in toConvert) {
29+
tempList.Add (go);
30+
}
31+
m_toConvert = tempList.ToArray ();
32+
33+
if (m_toConvert.Length >= 1) {
34+
m_prefabFileName = m_toConvert [0].name;
35+
this.SetFilename (m_prefabFileName);
3036
}
3137
}
3238

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,15 @@ public static bool CanInstall()
937937
return instance.dccOptionPaths.Count > 0;
938938
}
939939

940+
public static string GetProjectRelativePath(string fullPath){
941+
var assetRelativePath = FbxExporters.EditorTools.ExportSettings.ConvertToAssetRelativePath(fullPath);
942+
var projectRelativePath = "Assets/" + assetRelativePath;
943+
if (string.IsNullOrEmpty(assetRelativePath)) {
944+
throw new System.Exception("Path " + fullPath + " must be in the Assets folder.");
945+
}
946+
return projectRelativePath;
947+
}
948+
940949
/// <summary>
941950
/// The relative save paths for given absolute paths.
942951
/// This is relative to the Application.dataPath ; it uses '/' as the

0 commit comments

Comments
 (0)