Skip to content

Commit b685dba

Browse files
authored
Merge pull request #182 from Unity-Technologies/merge-austin-unite-branch
Uni-28714 Merge austin unite branch
2 parents cd36a8f + 7c895f6 commit b685dba

32 files changed

+1651
-1437
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ 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);
@@ -396,6 +397,10 @@ public static void CopyComponents(GameObject from, GameObject to){
396397
}
397398

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

400405
System.Type expectedType = component.GetType();
401406
Component toComponent = null;
@@ -414,7 +419,9 @@ public static void CopyComponents(GameObject from, GameObject to){
414419
if (!toComponent) {
415420
// It doesn't exist => create and copy.
416421
toComponent = to.AddComponent(component.GetType());
417-
EditorJsonUtility.FromJsonOverwrite(json, toComponent);
422+
if (toComponent) {
423+
EditorJsonUtility.FromJsonOverwrite (json, toComponent);
424+
}
418425
} else {
419426
// It exists => copy.
420427
// But we want to override that behaviour in a few

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 64 additions & 66 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 ();
@@ -114,23 +103,46 @@ public override void OnInspectorGUI() {
114103
int oldValue = exportSettings.selectedMayaApp;
115104
exportSettings.selectedMayaApp = EditorGUILayout.Popup(exportSettings.selectedMayaApp, options);
116105
if (exportSettings.selectedMayaApp == options.Length - 1) {
117-
var ext = "exe";
118-
#if UNITY_EDITOR_OSX
119-
ext = "app";
120-
#endif
106+
var ext = "";
107+
switch(Application.platform){
108+
case RuntimePlatform.WindowsEditor:
109+
ext = "exe";
110+
break;
111+
case RuntimePlatform.OSXEditor:
112+
ext = "app";
113+
break;
114+
default:
115+
throw new NotImplementedException ();
116+
}
121117
string mayaPath = EditorUtility.OpenFilePanel ("Select Maya Application", ExportSettings.kDefaultAdskRoot, ext);
122118

123119
// check that the path is valid and references the maya executable
124120
if (!string.IsNullOrEmpty (mayaPath)) {
121+
var md = Directory.GetParent (mayaPath);
122+
if (md.Parent.Name.ToLower ().StartsWith ("mayalt")) {
123+
Debug.LogError (string.Format("Unity Integration does not support Maya LT: \"{0}\"", md.FullName));
124+
exportSettings.selectedMayaApp = oldValue;
125+
return;
126+
}
127+
125128
if (!Path.GetFileNameWithoutExtension (mayaPath).ToLower ().Equals ("maya")) {
126129
// clicked on the wrong application, try to see if we can still find
127130
// maya in this directory.
128131
var mayaDir = new DirectoryInfo(Path.GetDirectoryName(mayaPath));
129-
#if UNITY_EDITOR_OSX
130-
var files = mayaDir.GetDirectories("*." + ext);
131-
#else
132-
var files = mayaDir.GetFiles ("*." + ext);
133-
#endif
132+
133+
FileSystemInfo[] files = null;
134+
135+
switch(Application.platform){
136+
case RuntimePlatform.WindowsEditor:
137+
files = mayaDir.GetFiles ("*." + ext);
138+
break;
139+
case RuntimePlatform.OSXEditor:
140+
files = mayaDir.GetDirectories ("*." + ext);
141+
break;
142+
default:
143+
throw new NotImplementedException ();
144+
}
145+
134146
bool foundMaya = false;
135147
foreach (var file in files) {
136148
var filename = Path.GetFileNameWithoutExtension (file.Name).ToLower ();
@@ -181,15 +193,18 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
181193
/// The path where all the different versions of Maya are installed
182194
/// by default. Depends on the platform.
183195
/// </summary>
184-
public const string kDefaultAdskRoot =
185-
#if UNITY_EDITOR_OSX
186-
"/Applications/Autodesk"
187-
#elif UNITY_EDITOR_LINUX
188-
"/usr/autodesk"
189-
#else // WINDOWS
190-
"C:/Program Files/Autodesk"
191-
#endif
192-
;
196+
public static string kDefaultAdskRoot {
197+
get{
198+
switch (Application.platform) {
199+
case RuntimePlatform.WindowsEditor:
200+
return "C:/Program Files/Autodesk";
201+
case RuntimePlatform.OSXEditor:
202+
return "/Applications/Autodesk";
203+
default:
204+
throw new NotImplementedException ();
205+
}
206+
}
207+
}
193208

194209
// Note: default values are set in LoadDefaults().
195210
public bool mayaCompatibleNames;
@@ -204,9 +219,6 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
204219

205220
public int selectedMayaApp = 0;
206221

207-
[SerializeField]
208-
public UnityEngine.Object turntableScene;
209-
210222
/// <summary>
211223
/// The path where Convert To Model will save the new fbx and prefab.
212224
///
@@ -233,7 +245,6 @@ protected override void LoadDefaults()
233245
centerObjects = true;
234246
keepOriginalAfterConvert = false;
235247
convertToModelSavePath = kDefaultSavePath;
236-
turntableScene = null;
237248
mayaOptionPaths = null;
238249
mayaOptionNames = null;
239250
}
@@ -317,23 +328,24 @@ private static void FindMayaInstalls() {
317328
/// <param name="location">Location of Maya install.</param>
318329
private static string GetMayaExePath(string location)
319330
{
320-
#if UNITY_EDITOR_OSX
321-
// MAYA_LOCATION on mac is set by Autodesk to be the
322-
// Contents directory. But let's make it easier on people
323-
// and allow just having it be the app bundle or a
324-
// directory that holds the app bundle.
325-
if (location.EndsWith(".app/Contents")) {
326-
return location + "/MacOS/Maya";
327-
} else if (location.EndsWith(".app")) {
328-
return location + "/Contents/MacOS/Maya";
329-
} else {
330-
return location + "/Maya.app/Contents/MacOS/Maya";
331+
switch (Application.platform) {
332+
case RuntimePlatform.WindowsEditor:
333+
return location + "/bin/maya.exe";
334+
case RuntimePlatform.OSXEditor:
335+
// MAYA_LOCATION on mac is set by Autodesk to be the
336+
// Contents directory. But let's make it easier on people
337+
// and allow just having it be the app bundle or a
338+
// directory that holds the app bundle.
339+
if (location.EndsWith(".app/Contents")) {
340+
return location + "/MacOS/Maya";
341+
} else if (location.EndsWith(".app")) {
342+
return location + "/Contents/MacOS/Maya";
343+
} else {
344+
return location + "/Maya.app/Contents/MacOS/Maya";
345+
}
346+
default:
347+
throw new NotImplementedException ();
331348
}
332-
#elif UNITY_EDITOR_LINUX
333-
return location + "/bin/maya";
334-
#else // WINDOWS
335-
return location + "/bin/maya.exe";
336-
#endif
337349
}
338350

339351
public static GUIContent[] GetMayaOptions(){
@@ -373,9 +385,9 @@ public static GUIContent[] GetMayaOptions(){
373385

374386
public static void AddMayaOption(string newOption){
375387
// on OSX we get a path ending in .app, which is not quite the exe
376-
#if UNITY_EDITOR_OSX
377-
newOption = GetMayaExePath(newOption);
378-
#endif
388+
if (Application.platform == RuntimePlatform.OSXEditor) {
389+
newOption = GetMayaExePath (newOption);
390+
}
379391

380392
var mayaOptionPaths = instance.mayaOptionPaths;
381393
if (mayaOptionPaths.Contains(newOption)) {
@@ -417,20 +429,6 @@ public static string GetSelectedMayaPath()
417429
return instance.mayaOptionPaths [instance.selectedMayaApp];
418430
}
419431

420-
public static string GetTurnTableSceneName(){
421-
if (instance.turntableScene) {
422-
return instance.turntableScene.name;
423-
}
424-
return null;
425-
}
426-
427-
public static string GetTurnTableScenePath(){
428-
if (instance.turntableScene) {
429-
return AssetDatabase.GetAssetPath (instance.turntableScene);
430-
}
431-
return null;
432-
}
433-
434432
/// <summary>
435433
/// The path where Convert To Model will save the new fbx and prefab.
436434
/// 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)