Skip to content

Commit a2a3f4a

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-29074-mayalt-plugin
# Conflicts: # Assets/FbxExporters/Editor/FbxExportSettings.cs
2 parents b537d12 + 79dfbba commit a2a3f4a

11 files changed

+113
-114
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
81
using System.IO;
92
using System.Collections.Generic;
103
using UnityEngine;

Assets/FbxExporters/Editor/EditorRotate.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
8-
9-
using System.Collections;
1+
using System.Collections;
102
using System.Collections.Generic;
113
using UnityEngine;
124
using UnityEditor;

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 96 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ public override void OnInspectorGUI() {
5252
exportSettings.centerObjects
5353
);
5454

55+
EditorGUILayout.Space();
56+
57+
GUILayout.BeginHorizontal();
58+
GUILayout.Label(new GUIContent("Export Format:", "Export the FBX file in the standard binary format." +
59+
" Select ASCII to export the FBX file in ASCII format."), GUILayout.Width(LabelWidth - 3));
60+
exportSettings.ExportFormatSelection = EditorGUILayout.Popup(exportSettings.ExportFormatSelection, new string[]{"Binary", "ASCII"});
61+
GUILayout.EndHorizontal();
62+
63+
EditorGUILayout.Space();
64+
5565
GUILayout.BeginHorizontal ();
5666
GUILayout.Label (new GUIContent (
5767
"Export Path:",
@@ -118,7 +128,7 @@ public override void OnInspectorGUI() {
118128
throw new System.NotImplementedException ();
119129
}
120130

121-
string dccPath = EditorUtility.OpenFilePanel ("Select Digital Content Creation Application", ExportSettings.kDefaultAdskRoot, ext);
131+
string dccPath = EditorUtility.OpenFilePanel ("Select Digital Content Creation Application", ExportSettings.GetFirstValidVendorLocation(), ext);
122132

123133
// check that the path is valid and references the maya executable
124134
if (!string.IsNullOrEmpty (dccPath)) {
@@ -139,7 +149,9 @@ public override void OnInspectorGUI() {
139149
}
140150
GUILayout.EndHorizontal ();
141151

142-
var installIntegrationContent = new GUIContent(
152+
EditorGUILayout.Space();
153+
154+
var installIntegrationContent = new GUIContent(
143155
"Install Unity Integration",
144156
"Install and configure the Unity integration for the selected 3D application so that you can import and export directly with this project.");
145157
if (GUILayout.Button (installIntegrationContent)) {
@@ -219,18 +231,37 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
219231
public const string kBlenderOptionName = "Blender ";
220232

221233
/// <summary>
222-
/// The path where all the different versions of Maya are installed
234+
/// The paths where all the different versions of Maya are installed
223235
/// by default. Depends on the platform.
224236
/// </summary>
225-
public static string kDefaultAdskRoot {
237+
public static string[] DCCVendorLocations {
226238
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 ();
239+
var environmentVariable = Environment.GetEnvironmentVariable("UNITY_FBX_3DAPP_VENDOR_LOCATIONS");
240+
if (environmentVariable != null)
241+
{
242+
string[] locations = environmentVariable.Split(';');
243+
List<string> locationsList = new List<string>();
244+
for (int i = 0; i < locations.Length; i++)
245+
{
246+
if (Directory.Exists(locations[i]))
247+
{
248+
locationsList.Add(locations[i]);
249+
}
250+
}
251+
if (locationsList.Count > 0)
252+
{
253+
return locationsList.ToArray();
254+
}
255+
}
256+
257+
switch (Application.platform)
258+
{
259+
case RuntimePlatform.WindowsEditor:
260+
return new string[] { "C:/Program Files/Autodesk", "D:/Program Files/Autodesk" };
261+
case RuntimePlatform.OSXEditor:
262+
return new string[] { "/Applications/Autodesk" };
263+
default:
264+
throw new NotImplementedException();
234265
}
235266
}
236267
}
@@ -239,6 +270,7 @@ public static string kDefaultAdskRoot {
239270
public bool mayaCompatibleNames;
240271
public bool centerObjects;
241272
public bool launchAfterInstallation;
273+
public int ExportFormatSelection;
242274

243275
public int selectedDCCApp = 0;
244276

@@ -267,6 +299,7 @@ protected override void LoadDefaults()
267299
mayaCompatibleNames = true;
268300
centerObjects = true;
269301
launchAfterInstallation = true;
302+
ExportFormatSelection = 0;
270303
convertToModelSavePath = kDefaultSavePath;
271304
dccOptionPaths = null;
272305
dccOptionNames = null;
@@ -437,48 +470,67 @@ private static void FindDCCInstalls() {
437470
var dccOptionName = instance.dccOptionNames;
438471
var dccOptionPath = instance.dccOptionPaths;
439472

440-
// If the location is given by the environment, use it.
441-
var location = System.Environment.GetEnvironmentVariable ("MAYA_LOCATION");
442-
if (!string.IsNullOrEmpty(location)) {
443-
location = location.TrimEnd('/');
444-
dccOptionPath.Add (GetMayaExePath (location.Replace ("\\", "/")));
445-
dccOptionName.Add ("MAYA_LOCATION");
446-
}
447-
448-
if (!Directory.Exists (kDefaultAdskRoot)) {
449-
// no autodesk products installed
450-
return;
451-
}
452-
// List that directory and find the right version:
453-
// either the newest version, or the exact version we wanted.
454-
var adskRoot = new System.IO.DirectoryInfo(kDefaultAdskRoot);
455-
foreach(var productDir in adskRoot.GetDirectories()) {
456-
var product = productDir.Name;
457-
458-
// Only accept those that start with 'maya' in either case.
459-
if (product.StartsWith ("maya", StringComparison.InvariantCultureIgnoreCase)) {
460-
string version = product.Substring ("maya".Length);
461-
dccOptionPath.Add (GetMayaExePath (productDir.FullName.Replace ("\\", "/")));
462-
dccOptionName.Add (GetUniqueDCCOptionName(kMayaOptionName + version));
473+
for (int i = 0; i < DCCVendorLocations.Length; i++)
474+
{
475+
if (!Directory.Exists(DCCVendorLocations[i]))
476+
{
477+
// no autodesk products installed
478+
continue;
463479
}
480+
// List that directory and find the right version:
481+
// either the newest version, or the exact version we wanted.
482+
var adskRoot = new System.IO.DirectoryInfo(DCCVendorLocations[i]);
483+
foreach (var productDir in adskRoot.GetDirectories())
484+
{
485+
var product = productDir.Name;
486+
487+
// Only accept those that start with 'maya' in either case.
488+
if (product.StartsWith ("maya", StringComparison.InvariantCultureIgnoreCase)) {
489+
string version = product.Substring ("maya".Length);
490+
dccOptionPath.Add (GetMayaExePath (productDir.FullName.Replace ("\\", "/")));
491+
dccOptionName.Add (GetUniqueDCCOptionName(kMayaOptionName + version));
492+
continue;
493+
}
464494

465-
if (product.StartsWith ("3ds max", StringComparison.InvariantCultureIgnoreCase)) {
466-
var exePath = string.Format ("{0}/{1}", productDir.FullName.Replace ("\\", "/"), "3dsmax.exe");
495+
if (product.StartsWith("3ds max", StringComparison.InvariantCultureIgnoreCase))
496+
{
497+
var exePath = string.Format("{0}/{1}", productDir.FullName.Replace("\\", "/"), "3dsmax.exe");
467498

468-
string version = product.Substring("3ds max ".Length);
469-
var maxOptionName = GetUniqueDCCOptionName(kMaxOptionName + version);
499+
string version = product.Substring("3ds max ".Length);
500+
var maxOptionName = GetUniqueDCCOptionName(kMaxOptionName + version);
470501

471-
if (IsEarlierThanMax2017 (maxOptionName)) {
472-
continue;
502+
if (IsEarlierThanMax2017(maxOptionName))
503+
{
504+
continue;
505+
}
506+
507+
dccOptionPath.Add(exePath);
508+
dccOptionName.Add(maxOptionName);
473509
}
474-
475-
dccOptionPath.Add (exePath);
476-
dccOptionName.Add (maxOptionName);
477510
}
478511
}
479512
instance.selectedDCCApp = instance.GetPreferredDCCApp();
480513
}
481514

515+
/// <summary>
516+
/// Returns the first valid folder in our list of vendor locations
517+
/// </summary>
518+
/// <returns>The first valid vendor location</returns>
519+
public static string GetFirstValidVendorLocation()
520+
{
521+
string[] locations = DCCVendorLocations;
522+
for (int i = 0; i < locations.Length; i++)
523+
{
524+
//Look through the list of locations we have and take the first valid one
525+
if (Directory.Exists(locations[i]))
526+
{
527+
return locations[i];
528+
}
529+
}
530+
//if no valid locations exist, just take us to the project folder
531+
return Directory.GetCurrentDirectory();
532+
}
533+
482534
/// <summary>
483535
/// Gets the maya exe at Maya install location.
484536
/// </summary>
@@ -537,6 +589,7 @@ public static GUIContent[] GetDCCOptions(){
537589
}
538590

539591
if (instance.dccOptionPaths.Count <= 0) {
592+
instance.selectedDCCApp = 0;
540593
return new GUIContent[]{
541594
new GUIContent("<No 3D Application found>")
542595
};

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
81
using System.IO;
92
using System.Collections.Generic;
103
using UnityEngine;
@@ -54,6 +47,12 @@ public class ModelExporter : System.IDisposable
5447

5548
public const string PACKAGE_UI_NAME = "FBX Exporter";
5649

50+
public enum ExportFormat
51+
{
52+
Binary = 0,
53+
ASCII = 1
54+
}
55+
5756
/// <summary>
5857
/// Create instance of exporter.
5958
/// </summary>
@@ -981,7 +980,11 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
981980

982981
// Initialize the exporter.
983982
// fileFormat must be binary if we are embedding textures
984-
int fileFormat = fbxManager.GetIOPluginRegistry ().FindWriterIDByDescription ("FBX ascii (*.fbx)");
983+
int fileFormat = -1;
984+
if (EditorTools.ExportSettings.instance.ExportFormatSelection == (int)ExportFormat.ASCII)
985+
{
986+
fileFormat = fbxManager.GetIOPluginRegistry().FindWriterIDByDescription("FBX ascii (*.fbx)");
987+
}
985988

986989
status = fbxExporter.Initialize (m_tempFilePath, fileFormat, fbxManager.GetIOSettings ());
987990
// Check that initialization of the fbxExporter was successful

Assets/FbxExporters/Editor/FbxPrefabInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public override void OnInspectorGUI() {
1818

1919
var fbxPrefabUtility = new FbxPrefabAutoUpdater.FbxPrefabUtility (fbxPrefab);
2020
var oldFbxAsset = fbxPrefabUtility.GetFbxAsset();
21-
var newFbxAsset = EditorGUILayout.ObjectField("Source Fbx Asset", oldFbxAsset,
21+
var newFbxAsset = EditorGUILayout.ObjectField(new GUIContent("Source Fbx Asset", "The FBX file that is linked to this Prefab"), oldFbxAsset,
2222
typeof(GameObject), allowSceneObjects: false) as GameObject;
2323
if (newFbxAsset && !AssetDatabase.GetAssetPath(newFbxAsset).EndsWith(".fbx")) {
2424
Debug.LogError("FbxPrefab must point to an Fbx asset (or none).");

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
81
using UnityEngine;
92

103
namespace FbxExporters

Assets/FbxExporters/Editor/UnitTests/DefaultSelectionTest.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
8-
using UnityEngine;
1+
using UnityEngine;
92
using UnityEditor;
103
using UnityEngine.TestTools;
114
using NUnit.Framework;

Assets/FbxExporters/Editor/UnitTests/ExporterTestBase.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
8-
using UnityEngine;
1+
using UnityEngine;
92
using UnityEditor;
103
using UnityEngine.TestTools;
114
using NUnit.Framework;

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
81
using UnityEngine;
92
using UnityEditor;
103
using NUnit.Framework;

Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
// ***********************************************************************
2-
// Copyright (c) 2017 Unity Technologies. All rights reserved.
3-
//
4-
// Licensed under the ##LICENSENAME##.
5-
// See LICENSE.md file in the project root for full license information.
6-
// ***********************************************************************
7-
8-
using UnityEngine;
1+
using UnityEngine;
92
using UnityEditor;
103
using UnityEngine.TestTools;
114
using NUnit.Framework;

0 commit comments

Comments
 (0)