You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uni-40523: defining all the cases and making them work
The spec wasn't clear about what would happen in which case. Now it should be, and unit tests make sure it's all happening.
Particular changes:
- now Convert returns the prefab, not the instance. That's because sometimes there isn't an instance. I had to change a few unit tests.
- if what we're converting is an fbx or an instance of an fbx, use it. That was mostly implemented before.
- if what we're converting is a prefab, update the prefab
- added unit tests to each part so we can make sure the complicated logic is properly implemented
- probably fixed a bug in file paths for prefabs in some cases; I didn't test whether I could actually trigger it
I also changed the ExporterTestBase ExportToFbx function to return the asset. Almost every call to that function wanted the asset rather than what it used to return which is its filename.
@@ -94,40 +94,84 @@ public static GameObject[] CreateInstantiatedModelPrefab (
94
94
/// <summary>
95
95
/// Convert one object (and the hierarchy below it) to an auto-updating prefab.
96
96
///
97
-
/// This returns a new object; the converted object may be modified or destroyed.
97
+
/// Returns the prefab asset that's linked to the fbx.
98
98
///
99
-
/// This refreshes the asset database.
100
-
///
101
-
/// If 'toConvert' is an asset, we return a prefab.
102
-
/// If 'toConvert' is an object in the scene, we return an instance of the prefab.
99
+
/// If 'toConvert' is:
100
+
/// (1) an object in the scene, then the hierarchy will be exported and a new auto-updating prefab created pointing to the new fbx
101
+
/// (2) the root of an fbx asset, or the root of an instance of an fbx asset, then a new auto-updating prefab will be created pointing to the existing fbx
102
+
/// (3) a prefab asset (but *not* if it's an instance of a prefab), then a new fbx asset will be exported and the prefab will be made to auto-update from the new fbx
103
103
/// </summary>
104
-
/// <returns>The instance that replaces 'toConvert' in the scene, or the prefab that replaces 'toConvert' in the project.</returns>
105
-
/// <param name="toConvert">GameObject hierarchy to replace with a prefab.</param>
106
-
/// <param name="fbxFullPath">Absolute platform-specific path to
107
-
/// the fbx file. May be null, in which case we construct a unique
/// to a directory in which to put the fbx file. Ignored if
112
-
/// fbxFullPath is specified. May be null, in which case we use the
113
-
/// export settings.</param>
104
+
/// <returns>The prefab asset linked to an fbx file.</returns>
105
+
/// <param name="toConvert">Object to convert.</param>
106
+
/// <param name="fbxFullPath">Absolute platform-specific path to the fbx file. If the file already exists, it will be overwritten. May be null, in which case we construct a unique filename. Ignored if 'toConvert' is an fbx asset or is an instance of one.</param>
107
+
/// <param name="fbxDirectoryFullPath">Absolute platform-specific path to a directory in which to put the fbx file under a unique filename. May be null, in which case we use the export settings. Ignored if 'fbxFullPath' is specified. Ignored if 'toConvert' is an fbx asset or an instance of one.</param>
108
+
/// <param name="prefabFullPath">Absolute platform-specific path to the prefab file. If the file already exists, it will be overwritten. May be null, in which case we construct a unique filename. Ignored if 'toConvert' is a prefab asset.</param>
109
+
/// <param name="prefabDirectoryFullPath">Absolute platform-specific path to a directory in which to put the prefab file under a unique filename. May be null, in which case we use the export settings. Ignored if 'prefabFullPath' is specified. Ignored if 'toConvert' is a prefab asset.
114
110
publicstaticGameObjectConvert(
115
111
GameObjecttoConvert,
116
112
stringfbxDirectoryFullPath=null,
117
113
stringfbxFullPath=null,
118
114
stringprefabDirectoryFullPath=null,
119
115
stringprefabFullPath=null,
120
-
EditorTools.IExportOptionsexportOptions=null
121
-
)
116
+
EditorTools.IExportOptionsexportOptions=null)
122
117
{
123
118
// If we selected the something that's already backed by an FBX, don't export.
/// Check whether GetOrCreateFbxAsset will be exporting an fbx file, or reusing one.
148
+
/// </summary>
149
+
publicstaticboolWillExportFbx(GameObjectgo){
150
+
returnGetFbxAssetOrNull(go)==null;
151
+
}
152
+
153
+
/// <summary>
154
+
/// Return an FBX asset that corresponds to 'toConvert'.
155
+
///
156
+
/// If 'toConvert' is the root of an FBX asset, return it.
157
+
///
158
+
/// If it's an instance in a scene the points to the root of an FBX asset, return that asset.
159
+
///
160
+
/// Otherwise, export according to the paths and options, and return the new asset.
161
+
/// </summary>
162
+
/// <param name="toConvert">GameObject for which we want an fbx asset</param>
163
+
/// <param name="fbxDirectoryFullPath">Export will choose an appropriate filename in this directory. Ignored if fbxFullPath is set. Ignored if toConvert is an fbx asset or an instance of an fbx.</param>
164
+
/// <param name="fbxDirectoryFullPath">Export will create this file. Overrides fbxDirectoryFullPath. Ignored if toConvert is an fbx asset or an instance of an fbx.</param>
165
+
/// <returns>The root of a model prefab asset.</returns>
0 commit comments