Skip to content

Commit a67cb5f

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-27977-generalize-DCC-app-selection
# Conflicts: # Assets/FbxExporters/Editor/FbxExportSettings.cs # Assets/FbxExporters/Editor/InstallIntegration.cs # CMakeLists.txt
2 parents 8e08854 + b685dba commit a67cb5f

32 files changed

+1628
-1426
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,21 @@ public static GameObject Convert (
199199
Object.DestroyImmediate(fbxPrefab);
200200
}
201201
fbxPrefab = unityGO.AddComponent<FbxPrefab>();
202-
fbxPrefab.SetSourceModel(unityMainAsset);
202+
var fbxPrefabUtility = new FbxPrefabAutoUpdater.FbxPrefabUtility (fbxPrefab);
203+
fbxPrefabUtility.SetSourceModel(unityMainAsset);
203204

204205
// Disconnect from the FBX file.
205206
PrefabUtility.DisconnectPrefabInstance(unityGO);
206207

207208
// Create a prefab from the instantiated and componentized unityGO.
208209
var prefabFileName = Path.ChangeExtension(projectRelativePath, ".prefab");
209-
var prefab = PrefabUtility.CreatePrefab(prefabFileName, unityGO);
210+
var prefab = PrefabUtility.CreatePrefab(prefabFileName, unityGO, ReplacePrefabOptions.ConnectToPrefab);
210211
if (!prefab) {
211212
throw new System.Exception(
212213
string.Format("Failed to create prefab asset in [{0}] from fbx [{1}]",
213214
prefabFileName, fbxFullPath));
214215
}
215216

216-
// Connect to the prefab file.
217-
unityGO = PrefabUtility.ConnectGameObjectToPrefab(unityGO, prefab);
218-
219217
// Remove (now redundant) gameobject
220218
bool actuallyKeepOriginal;
221219
switch(keepOriginal) {
@@ -399,6 +397,10 @@ public static void CopyComponents(GameObject from, GameObject to){
399397
}
400398

401399
var json = EditorJsonUtility.ToJson(component);
400+
if (string.IsNullOrEmpty (json)) {
401+
// this happens for missing scripts
402+
continue;
403+
}
402404

403405
System.Type expectedType = component.GetType();
404406
Component toComponent = null;
@@ -417,7 +419,9 @@ public static void CopyComponents(GameObject from, GameObject to){
417419
if (!toComponent) {
418420
// It doesn't exist => create and copy.
419421
toComponent = to.AddComponent(component.GetType());
420-
EditorJsonUtility.FromJsonOverwrite(json, toComponent);
422+
if (toComponent) {
423+
EditorJsonUtility.FromJsonOverwrite (json, toComponent);
424+
}
421425
} else {
422426
// It exists => copy.
423427
// But we want to override that behaviour in a few

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ public override void OnInspectorGUI() {
8585
}
8686
}
8787
}
88-
GUILayout.EndHorizontal ();
89-
GUILayout.BeginHorizontal ();
90-
91-
GUILayout.Label (new GUIContent (
92-
"Turntable Scene:",
93-
"Scene to use for reviewing models. If none, a scene will be created on review."));
94-
95-
exportSettings.turntableScene = EditorGUILayout.ObjectField (
96-
exportSettings.turntableScene, typeof(SceneAsset), false
97-
);
98-
9988
GUILayout.EndHorizontal ();
10089

10190
EditorGUILayout.Space ();
@@ -130,6 +119,13 @@ public override void OnInspectorGUI() {
130119

131120
// check that the path is valid and references the maya executable
132121
if (!string.IsNullOrEmpty (dccPath)) {
122+
var md = Directory.GetParent (dccPath);
123+
if (md.Parent.Name.ToLower ().StartsWith ("mayalt")) {
124+
Debug.LogError (string.Format("Unity Integration does not support Maya LT: \"{0}\"", md.FullName));
125+
exportSettings.selectedDCCApp = oldValue;
126+
return;
127+
}
128+
133129
ExportSettings.DCCType foundDCC = ExportSettings.DCCType.Maya;
134130
var foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Maya);
135131
if (foundDCCPath == null && Application.platform == RuntimePlatform.WindowsEditor) {
@@ -138,6 +134,8 @@ public override void OnInspectorGUI() {
138134
} else {
139135
foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Max);
140136
foundDCC = ExportSettings.DCCType.Max;
137+
}
138+
141139
}
142140
}
143141
if (foundDCCPath == null) {
@@ -224,15 +222,18 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
224222
/// The path where all the different versions of Maya are installed
225223
/// by default. Depends on the platform.
226224
/// </summary>
227-
public const string kDefaultAdskRoot =
228-
#if UNITY_EDITOR_OSX
229-
"/Applications/Autodesk"
230-
#elif UNITY_EDITOR_LINUX
231-
"/usr/autodesk"
232-
#else // WINDOWS
233-
"C:/Program Files/Autodesk"
234-
#endif
235-
;
225+
public static string kDefaultAdskRoot {
226+
get{
227+
switch (Application.platform) {
228+
case RuntimePlatform.WindowsEditor:
229+
return "C:/Program Files/Autodesk";
230+
case RuntimePlatform.OSXEditor:
231+
return "/Applications/Autodesk";
232+
default:
233+
throw new NotImplementedException ();
234+
}
235+
}
236+
}
236237

237238
// Note: default values are set in LoadDefaults().
238239
public bool mayaCompatibleNames;
@@ -247,9 +248,6 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
247248

248249
public int selectedDCCApp = 0;
249250

250-
[SerializeField]
251-
public UnityEngine.Object turntableScene;
252-
253251
/// <summary>
254252
/// The path where Convert To Model will save the new fbx and prefab.
255253
///
@@ -276,7 +274,6 @@ protected override void LoadDefaults()
276274
centerObjects = true;
277275
keepOriginalAfterConvert = false;
278276
convertToModelSavePath = kDefaultSavePath;
279-
turntableScene = null;
280277
dccOptionPaths = null;
281278
dccOptionNames = null;
282279
}
@@ -371,23 +368,24 @@ private static void FindDCCInstalls() {
371368
/// <param name="location">Location of Maya install.</param>
372369
private static string GetMayaExePath(string location)
373370
{
374-
#if UNITY_EDITOR_OSX
375-
// MAYA_LOCATION on mac is set by Autodesk to be the
376-
// Contents directory. But let's make it easier on people
377-
// and allow just having it be the app bundle or a
378-
// directory that holds the app bundle.
379-
if (location.EndsWith(".app/Contents")) {
380-
return location + "/MacOS/Maya";
381-
} else if (location.EndsWith(".app")) {
382-
return location + "/Contents/MacOS/Maya";
383-
} else {
384-
return location + "/Maya.app/Contents/MacOS/Maya";
371+
switch (Application.platform) {
372+
case RuntimePlatform.WindowsEditor:
373+
return location + "/bin/maya.exe";
374+
case RuntimePlatform.OSXEditor:
375+
// MAYA_LOCATION on mac is set by Autodesk to be the
376+
// Contents directory. But let's make it easier on people
377+
// and allow just having it be the app bundle or a
378+
// directory that holds the app bundle.
379+
if (location.EndsWith(".app/Contents")) {
380+
return location + "/MacOS/Maya";
381+
} else if (location.EndsWith(".app")) {
382+
return location + "/Contents/MacOS/Maya";
383+
} else {
384+
return location + "/Maya.app/Contents/MacOS/Maya";
385+
}
386+
default:
387+
throw new NotImplementedException ();
385388
}
386-
#elif UNITY_EDITOR_LINUX
387-
return location + "/bin/maya";
388-
#else // WINDOWS
389-
return location + "/bin/maya.exe";
390-
#endif
391389
}
392390

393391
public static GUIContent[] GetDCCOptions(){
@@ -515,20 +513,6 @@ public static string GetSelectedDCCPath()
515513
return instance.dccOptionPaths [instance.selectedDCCApp];
516514
}
517515

518-
public static string GetTurnTableSceneName(){
519-
if (instance.turntableScene) {
520-
return instance.turntableScene.name;
521-
}
522-
return null;
523-
}
524-
525-
public static string GetTurnTableScenePath(){
526-
if (instance.turntableScene) {
527-
return AssetDatabase.GetAssetPath (instance.turntableScene);
528-
}
529-
return null;
530-
}
531-
532516
/// <summary>
533517
/// The path where Convert To Model will save the new fbx and prefab.
534518
/// This is relative to the Application.dataPath ; it uses '/' as the

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class ModelExporter : System.IDisposable
5252

5353
const int UnitScaleFactor = 100;
5454

55+
public const string PACKAGE_UI_NAME = "FBX Exporter";
56+
5557
/// <summary>
5658
/// Create instance of exporter.
5759
/// </summary>
@@ -953,7 +955,6 @@ public enum TransformExportType { Local, Global, Reset };
953955
public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
954956
{
955957
exportCancelled = false;
956-
Verbose = true;
957958

958959
// Export first to a temporary file
959960
// in case the export is cancelled.
@@ -1006,7 +1007,7 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
10061007
fbxSceneInfo.mRevision = "1.0";
10071008
fbxSceneInfo.mKeywords = Keywords;
10081009
fbxSceneInfo.mComment = Comments;
1009-
fbxSceneInfo.Original_ApplicationName.Set("Unity FbxExporter Plugin");
1010+
fbxSceneInfo.Original_ApplicationName.Set(string.Format("Unity {0}", PACKAGE_UI_NAME));
10101011
// set last saved to be the same as original, as this is a new file.
10111012
fbxSceneInfo.LastSaved_ApplicationName.Set(fbxSceneInfo.Original_ApplicationName.Get());
10121013

@@ -1181,7 +1182,7 @@ public static bool OnValidateMenuItem ()
11811182
public static void DisplayNoSelectionDialog()
11821183
{
11831184
UnityEditor.EditorUtility.DisplayDialog (
1184-
"Fbx Exporter Warning",
1185+
string.Format("{0} Warning", PACKAGE_UI_NAME),
11851186
"No GameObjects selected for export.",
11861187
"Ok");
11871188
}
@@ -1566,7 +1567,7 @@ public void Dispose ()
15661567
{
15671568
}
15681569

1569-
public bool Verbose { private set; get; }
1570+
public bool Verbose { private set {;} get { return Debug.unityLogger.logEnabled; } }
15701571

15711572
/// <summary>
15721573
/// manage the selection of a filename

0 commit comments

Comments
 (0)