Skip to content

Commit 5a13fa1

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-23199-minimal-Unity-turntable-window
2 parents 5ce51c2 + 80e99ec commit 5a13fa1

File tree

7 files changed

+108
-36
lines changed

7 files changed

+108
-36
lines changed

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,25 @@ private static void UnloadModel (Object model)
7070

7171
private static Object LoadModel (string fbxFileName)
7272
{
73-
Object model = null;
73+
GameObject modelGO = null;
7474

7575
// make relative to UnityProject folder.
7676
string relFileName = System.IO.Path.Combine ("Assets", FbxExporters.EditorTools.ExportSettings.ConvertToAssetRelativePath (fbxFileName));
7777

7878
Object unityMainAsset = UnityEditor.AssetDatabase.LoadMainAssetAtPath (relFileName);
7979

8080
if (unityMainAsset) {
81-
model = UnityEditor.PrefabUtility.InstantiatePrefab (unityMainAsset);
81+
modelGO = UnityEditor.PrefabUtility.InstantiatePrefab (unityMainAsset) as GameObject;
82+
83+
GameObject turntableGO = GameObject.Find ("TurnTable");
84+
if (turntableGO!=null)
85+
{
86+
modelGO.transform.parent = turntableGO.transform;
87+
}
8288
}
8389
UnityEditor.Selection.objects = new Object[]{model};
8490

85-
return model;
91+
return modelGO as Object;
8692
}
8793

8894
private static void LoadLastSavedModel ()

Assets/FbxExporters/Editor/UnitTests/ExportPerformanceTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void TestPerformance ()
6262
{
6363
Assert.IsNotNull (m_toExport);
6464

65-
var filename = GetRandomFileNamePath();
65+
var filename = GetRandomFbxFilePath();
6666

6767
UnityEngine.Debug.unityLogger.logEnabled = false;
6868

@@ -77,4 +77,4 @@ public void TestPerformance ()
7777
Assert.LessOrEqual(m_stopwatch.ElapsedMilliseconds, PerformanceThresholdMilliseconds);
7878
}
7979
}
80-
}
80+
}

Assets/FbxExporters/Editor/UnitTests/ExporterTestBase.cs

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ protected string filePath {
3737

3838
private string MakeFileName(string baseName = null, string prefixName = null, string extName = null)
3939
{
40-
if (baseName==null)
41-
baseName = Path.GetRandomFileName();
40+
if (baseName==null) {
41+
// GetRandomFileName makes a random 8.3 filename
42+
// We don't want the extension.
43+
baseName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
44+
}
4245

4346
if (prefixName==null)
4447
prefixName = this.fileNamePrefix;
@@ -49,7 +52,31 @@ private string MakeFileName(string baseName = null, string prefixName = null, st
4952
return prefixName + baseName + extName;
5053
}
5154

52-
protected string GetRandomFileNamePath(string pathName = null, string prefixName = null, string extName = null)
55+
/// <summary>
56+
/// Create a random path for a file.
57+
///
58+
/// By default the pathName is null, which defaults to a particular
59+
/// folder in the Assets folder that will be deleted on termination of
60+
/// this test.
61+
///
62+
/// By default the prefix is a fixed string. You can set it differently if you care.
63+
///
64+
/// By default the extension is ".fbx". You can set it differently if you care.
65+
///
66+
/// By default we use platform path separators. If you want a random
67+
/// asset path e.g. for AssetDatabase.LoadMainAssetAtPath or for
68+
/// PrefabUtility.CreatePrefab, you need to use the '/' as separator
69+
/// (even on windows).
70+
///
71+
/// See also convenience functions like:
72+
/// GetRandomPrefabAssetPath()
73+
/// GetRandomFbxFilePath()
74+
/// </summary>
75+
protected string GetRandomFileNamePath(
76+
string pathName = null,
77+
string prefixName = null,
78+
string extName = null,
79+
bool unityPathSeparator = false)
5380
{
5481
string temp;
5582

@@ -60,12 +87,32 @@ protected string GetRandomFileNamePath(string pathName = null, string prefixName
6087
// repeat until you find a file that does not already exist
6188
do {
6289
temp = Path.Combine (pathName, MakeFileName(prefixName: prefixName, extName: extName));
63-
6490
} while(File.Exists (temp));
6591

92+
// Unity asset paths need a slash on all platforms.
93+
if (unityPathSeparator) {
94+
temp = temp.Replace('\\', '/');
95+
}
96+
6697
return temp;
6798
}
6899

100+
/// <summary>
101+
/// Return a random .fbx path that you can use in
102+
/// the File APIs.
103+
/// </summary>
104+
protected string GetRandomFbxFilePath() {
105+
return GetRandomFileNamePath(extName: ".fbx", unityPathSeparator: false);
106+
}
107+
108+
/// <summary>
109+
/// Return a random .prefab path that you can use in
110+
/// PrefabUtility.CreatePrefab.
111+
/// </summary>
112+
protected string GetRandomPrefabAssetPath() {
113+
return GetRandomFileNamePath(extName: ".prefab", unityPathSeparator: true);
114+
}
115+
69116
/// <summary>
70117
/// Creates a test hierarchy.
71118
///

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77

88
using UnityEngine;
99
using UnityEditor;
10-
using UnityEngine.TestTools;
1110
using NUnit.Framework;
1211
using System.IO;
1312
using System.Collections.Generic;
14-
using FbxSdk;
1513

1614
namespace FbxExporters.UnitTests
1715
{
@@ -37,7 +35,7 @@ public void Init ()
3735
// Delete the object right away (don't even wait for term).
3836
var fbxInstance = PrefabUtility.InstantiatePrefab(m_fbx) as GameObject;
3937
fbxInstance.AddComponent<FbxPrefab>().SetSourceModel(m_fbx);
40-
m_prefabPath = GetRandomFileNamePath(extName: ".prefab");
38+
m_prefabPath = GetRandomPrefabAssetPath();
4139
m_prefab = PrefabUtility.CreatePrefab(m_prefabPath, fbxInstance);
4240
AssetDatabase.Refresh ();
4341
Assert.AreEqual(m_prefabPath, AssetDatabase.GetAssetPath(m_prefab));
@@ -110,17 +108,17 @@ public void ExpensivePerformanceTest ()
110108
//
111109
// Then modify one fbx model. Shouldn't take longer than 1s.
112110
var hierarchy = CreateGameObject("the_root");
113-
var baseName = GetRandomFileNamePath(extName: "");
114-
FbxExporters.Editor.ModelExporter.ExportObject(baseName + ".fbx", hierarchy);
111+
var baseName = GetRandomFbxFilePath();
112+
FbxExporters.Editor.ModelExporter.ExportObject(baseName, hierarchy);
115113

116114
// Create N fbx models by copying files. Import them all at once.
117115
var names = new string[n];
118116
names[0] = baseName;
119117
stopwatch.Reset();
120118
stopwatch.Start();
121119
for(int i = 1; i < n; ++i) {
122-
names[i] = GetRandomFileNamePath(extName : "");
123-
System.IO.File.Copy(names[0] + ".fbx", names[i] + ".fbx");
120+
names[i] = GetRandomFbxFilePath();
121+
System.IO.File.Copy(names[0], names[i]);
124122
}
125123
Debug.Log("Created fbx files in " + stopwatch.ElapsedMilliseconds);
126124

@@ -136,7 +134,7 @@ public void ExpensivePerformanceTest ()
136134
stopwatch.Start();
137135
var fbxFiles = new GameObject[n / 2];
138136
for(int i = 0; i < n / 2; ++i) {
139-
fbxFiles[i] = AssetDatabase.LoadMainAssetAtPath(names[i] + ".fbx") as GameObject;
137+
fbxFiles[i] = AssetDatabase.LoadMainAssetAtPath(names[i]) as GameObject;
140138
Assert.IsTrue(fbxFiles[i]);
141139
}
142140
Debug.Log("Loaded fbx files in " + stopwatch.ElapsedMilliseconds);
@@ -148,34 +146,35 @@ public void ExpensivePerformanceTest ()
148146
Assert.IsTrue(instance);
149147
var fbxPrefab = instance.AddComponent<FbxPrefab>();
150148
fbxPrefab.SetSourceModel(fbxFiles[i]);
151-
UnityEditor.PrefabUtility.CreatePrefab(names[i] + ".prefab", fbxFiles[i]);
149+
PrefabUtility.CreatePrefab(GetRandomPrefabAssetPath(), fbxFiles[i]);
152150
}
153151
Debug.Log("Created prefabs in " + stopwatch.ElapsedMilliseconds);
154152

155153
// Export a new hierarchy and update one fbx file.
156154
// Make sure we're timing just the assetdatabase refresh by
157155
// creating a file and then copying it, and not the FbxExporter.
158156
var newHierarchy = CreateHierarchy();
159-
FbxExporters.Editor.ModelExporter.ExportObject(names[0] + "_new.fbx", newHierarchy);
157+
var newHierarchyName = GetRandomFbxFilePath();
158+
FbxExporters.Editor.ModelExporter.ExportObject(newHierarchyName, newHierarchy);
160159
try {
161160
UnityEngine.Debug.unityLogger.logEnabled = false;
162161
stopwatch.Reset ();
163162
stopwatch.Start ();
164-
File.Copy(names[0] + "_new.fbx", names[0] + ".fbx", overwrite: true);
163+
File.Copy(newHierarchyName, names[0], overwrite: true);
165164
AssetDatabase.Refresh(); // force the update right now.
166165
} finally {
167166
UnityEngine.Debug.unityLogger.logEnabled = true;
168167
}
169168
Debug.Log("Import (one change) in " + stopwatch.ElapsedMilliseconds);
170169
Assert.LessOrEqual(stopwatch.ElapsedMilliseconds, NoUpdateTimeLimit);
171170

172-
// Try what happens when nothing gets updated.
171+
// Try what happens when no prefab gets updated.
173172
try {
174173
UnityEngine.Debug.unityLogger.logEnabled = false;
175174
stopwatch.Reset ();
176175
stopwatch.Start ();
177-
string newHierarchyFbxFile = GetRandomFileNamePath(extName : ".fbx");
178-
File.Copy(names[0] + ".fbx", newHierarchyFbxFile);
176+
string newHierarchyFbxFile = GetRandomFbxFilePath();
177+
File.Copy(names[0], newHierarchyFbxFile);
179178
AssetDatabase.Refresh(); // force the update right now.
180179
} finally {
181180
UnityEngine.Debug.unityLogger.logEnabled = true;

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void Init() {
3535
// Convert it to FBX. The asset file will be deleted automatically
3636
// on termination.
3737
var fbxAsset = FbxExporters.Editor.ModelExporter.ExportObject(
38-
GetRandomFileNamePath(), m_original);
38+
GetRandomFbxFilePath(), m_original);
3939
m_source = AssetDatabase.LoadMainAssetAtPath(fbxAsset) as GameObject;
4040
Assert.IsTrue(m_source);
4141

@@ -46,7 +46,7 @@ public void Init() {
4646
fbxPrefab.SetSourceModel(m_source);
4747
fbxPrefab.SetAutoUpdate(true);
4848
m_autoPrefab = PrefabUtility.CreatePrefab(
49-
GetRandomFileNamePath(extName: ".prefab"),
49+
GetRandomPrefabAssetPath(),
5050
prefabInstance);
5151
}
5252

@@ -57,7 +57,7 @@ public void Init() {
5757
fbxPrefab.SetSourceModel(m_source);
5858
fbxPrefab.SetAutoUpdate(false);
5959
m_manualPrefab = PrefabUtility.CreatePrefab(
60-
GetRandomFileNamePath(extName: ".prefab"),
60+
GetRandomPrefabAssetPath(),
6161
prefabInstance);
6262
}
6363
}
@@ -148,7 +148,7 @@ public void BasicTest() {
148148
// (but is a totally different file). This will cause an update
149149
// immediately.
150150
var fbxAsset = FbxExporters.Editor.ModelExporter.ExportObject(
151-
GetRandomFileNamePath(), m_original);
151+
GetRandomFbxFilePath(), m_original);
152152
var newSource = AssetDatabase.LoadMainAssetAtPath(fbxAsset) as GameObject;
153153
Assert.IsTrue(newSource);
154154
manualPrefabComponent.SetSourceModel(newSource);

Assets/FbxExporters/README.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
Copyright (c) 2017 Unity Technologies. All rights reserved.
44

5-
Licensed under the ##LICENSENAME##.
6-
See LICENSE.md file for full license information.
5+
See LICENSE.txt file for full license information.
76

8-
**Version**: 0.0.9a-sprint20
7+
**Version**: 0.0.9a
98

109
Requirements
1110
------------
@@ -20,14 +19,19 @@ You can install the package and integrations from the command-line using the fol
2019
MacOS:
2120

2221
# Configure where Unity is installed
23-
# UNITY3D_VERSION=" 2017.1.0f3"
24-
UNITY3D_PATH="/Applications/Unity${UNITY3D_VERSION}/Unity.app/Contents/MacOS/Unity"
25-
26-
# Configure where unitypackage is located
27-
PACKAGE_PATH=`ls -t ~/Development/FbxExporters/FbxExporters_*.unitypackage | head -1`
22+
if [ ! -f "${UNITY3D_PATH}" ]; then
23+
UNITY3D_PATH="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
24+
fi
2825

2926
# Configure which Unity project to install package
30-
PROJECT_PATH=~/Development/FbxExporters
27+
if [ ! -d "${PROJECT_PATH}" ]; then
28+
PROJECT_PATH=~/Development/FbxExporters
29+
fi
30+
31+
# Configure where unitypackage is located
32+
if [ ! -f "${PACKAGE_PATH}" ]; then
33+
PACKAGE_PATH=`ls -t ${PROJECT_PATH}/FbxExporters_*.unitypackage | head -1`
34+
fi
3135

3236
if [ ! -f "${UNITY3D_PATH}" ]; then
3337
echo "Unity is not installed"

RELEASE_NOTES.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
RELEASE NOTES
22

3+
**Version**: 0.0.9a
4+
5+
* Auto updater for instanced prefabs
6+
7+
Convert To Prefab will now create both a .prefab file and a FBX file from the selected GameObject hierarchy. The newly instanced prefab will automatically update whenever the FBX file changes. The instanced prefab will now include updates whenever objects are added or removed from the source FBX file.
8+
9+
* Maya-to-Unity turntable review workflow
10+
11+
Unity One Click integration for Maya 2017 now includes a "Review in Unity" feature.
12+
13+
You can review how your Model looks in Unity by clicking "Unity->Review" menu Item. This will start Unity and your Model will be loaded into "FbxExporters_TurnTableReview" scene. If the scene cannot be found then an empty scene will be created for you. If the scene contains a "Turntable" object then your model will be parented under that object.
14+
15+
While Unity has the "FbxExporters_TurnTableReview" scene active it will automatically update each time you publish a Model. If you've changed the active scene and want to go back to the reviewing you can run the command "FbxExporters->Turntable Review->Auto Load Last Saved Prefab". If you have unmodified scene changes in a previously saved scene then you'll be prompted to save these changes before the active scene is switched for you. If the scene is an Untitled but modified scene then these changes will be left as-is and the active scene will be switched.
16+
17+
* FBXSDK C# unitypackage with docs ready for release
18+
319
**Version**: 0.0.8a
420

521
NEW FEATURES

0 commit comments

Comments
 (0)