@@ -28,6 +28,12 @@ public abstract class ExportOptionsEditorWindow : EditorWindow
28
28
29
29
protected string m_exportFileName = "" ;
30
30
31
+ private bool m_disableTransferAnim = false ;
32
+ protected bool DisableTransferAnim { get { return m_disableTransferAnim ; } set { m_disableTransferAnim = value ; } }
33
+
34
+ private bool m_disableNameSelection = false ;
35
+ protected bool DisableNameSelection { get { return m_disableNameSelection ; } set { m_disableNameSelection = value ; } }
36
+
31
37
protected UnityEditor . Editor m_innerEditor ;
32
38
protected FbxExportPresetSelectorReceiver m_receiver ;
33
39
@@ -105,10 +111,6 @@ public void OnPresetSelectionChanged()
105
111
/// </summary>
106
112
protected virtual void CreateCustomUI ( ) { }
107
113
108
- protected virtual bool DisableNameSelection ( ) {
109
- return false ;
110
- }
111
-
112
114
protected abstract void ShowPresetReceiver ( ) ;
113
115
114
116
protected void ShowPresetReceiver ( UnityEngine . Object target ) {
@@ -141,7 +143,7 @@ protected void OnGUI ()
141
143
"Export Name:" ,
142
144
"Filename to save model to." ) , GUILayout . Width ( LabelWidth - TextFieldAlignOffset ) ) ;
143
145
144
- EditorGUI . BeginDisabledGroup ( DisableNameSelection ( ) ) ;
146
+ EditorGUI . BeginDisabledGroup ( DisableNameSelection ) ;
145
147
// Show the export name with an uneditable ".fbx" at the end
146
148
//-------------------------------------
147
149
EditorGUILayout . BeginVertical ( ) ;
@@ -202,15 +204,18 @@ protected void OnGUI ()
202
204
CreateCustomUI ( ) ;
203
205
204
206
EditorGUILayout . Space ( ) ;
207
+
208
+ EditorGUI . BeginDisabledGroup ( DisableTransferAnim ) ;
205
209
EditorGUI . indentLevel -- ;
206
210
GUILayout . BeginHorizontal ( ) ;
207
211
EditorGUILayout . LabelField ( new GUIContent ( "Transfer Animation" , "Select bone to transfer root motion animation to." ) , GUILayout . Width ( LabelWidth - FieldOffset ) ) ;
208
212
GUILayout . EndHorizontal ( ) ;
209
213
EditorGUI . indentLevel ++ ;
210
214
TransferAnimationSource = EditorGUILayout . ObjectField ( "Source" , TransferAnimationSource , typeof ( Transform ) , allowSceneObjects : true ) as Transform ;
211
215
TransferAnimationDest = EditorGUILayout . ObjectField ( "Destination" , TransferAnimationDest , typeof ( Transform ) , allowSceneObjects : true ) as Transform ;
212
-
213
216
EditorGUILayout . Space ( ) ;
217
+ EditorGUI . EndDisabledGroup ( ) ;
218
+
214
219
EditorGUI . indentLevel -- ;
215
220
m_showOptions = EditorGUILayout . Foldout ( m_showOptions , "Options" ) ;
216
221
EditorGUI . indentLevel ++ ;
@@ -266,14 +271,55 @@ public class ExportModelEditorWindow : ExportOptionsEditorWindow
266
271
private UnityEngine . Object [ ] m_toExport ;
267
272
268
273
private bool m_isTimelineAnim = false ;
274
+ protected bool IsTimelineAnim {
275
+ get { return m_isTimelineAnim ; }
276
+ set {
277
+ m_isTimelineAnim = value ;
278
+ if ( m_isTimelineAnim ) {
279
+ ExportSettings . instance . exportModelSettings . info . SetModelAnimIncludeOption ( ExportSettings . Include . Anim ) ;
280
+ }
281
+ if ( m_innerEditor ) {
282
+ var exportModelSettingsEditor = m_innerEditor as ExportModelSettingsEditor ;
283
+ if ( exportModelSettingsEditor ) {
284
+ exportModelSettingsEditor . DisableIncludeDropdown ( m_isTimelineAnim ) ;
285
+ }
286
+ }
287
+ }
288
+ }
289
+
269
290
private bool m_singleHierarchyExport = true ;
291
+ protected bool SingleHierarchyExport {
292
+ get { return m_singleHierarchyExport ; }
293
+ set {
294
+ m_singleHierarchyExport = value ;
295
+
296
+ if ( m_innerEditor ) {
297
+ var exportModelSettingsEditor = m_innerEditor as ExportModelSettingsEditor ;
298
+ if ( exportModelSettingsEditor ) {
299
+ exportModelSettingsEditor . SetIsSingleHierarchy ( m_singleHierarchyExport ) ;
300
+ }
301
+ }
302
+ }
303
+ }
304
+
270
305
private bool m_isPlayableDirector = false ;
306
+ protected bool IsPlayableDirector {
307
+ get { return m_isPlayableDirector ; }
308
+ set {
309
+ m_isPlayableDirector = value ;
310
+ DisableNameSelection = m_isPlayableDirector ;
311
+ }
312
+ }
271
313
272
314
protected override Transform TransferAnimationSource {
273
315
get {
274
316
return ExportSettings . instance . exportModelSettings . info . AnimationSource ;
275
317
}
276
318
set {
319
+ // source must be ancestor to dest
320
+
321
+ // must be in same hierarchy as selected GO
322
+
277
323
ExportSettings . instance . exportModelSettings . info . SetAnimationSource ( value ) ;
278
324
}
279
325
}
@@ -295,9 +341,9 @@ public static void Init (IEnumerable<UnityEngine.Object> toExport, string filena
295
341
filename = window . GetFilenameFromObjects ( ) ;
296
342
}
297
343
window . InitializeWindow ( filename ) ;
298
- window . SetAnimationExportType ( isTimelineAnim ) ;
299
- window . SetSingleHierarchyExport ( numObjects == 1 ) ;
300
- window . SetIsPlayableDirector ( isPlayableDirector ) ;
344
+ window . IsTimelineAnim = isTimelineAnim ;
345
+ window . SingleHierarchyExport = ( numObjects == 1 ) ;
346
+ window . IsPlayableDirector = isPlayableDirector ;
301
347
window . Show ( ) ;
302
348
}
303
349
@@ -311,39 +357,12 @@ protected int SetGameObjectsToExport(IEnumerable<UnityEngine.Object> toExport){
311
357
TransferAnimationSource = go . transform ;
312
358
TransferAnimationDest = go . transform ;
313
359
}
314
- }
360
+ }
361
+ DisableTransferAnim = m_toExport . Length > 1 ;
315
362
316
363
return m_toExport . Length ;
317
364
}
318
365
319
- private void SetAnimationExportType ( bool isTimelineAnim ) {
320
- m_isTimelineAnim = isTimelineAnim ;
321
- if ( m_isTimelineAnim ) {
322
- ExportSettings . instance . exportModelSettings . info . SetModelAnimIncludeOption ( ExportSettings . Include . Anim ) ;
323
- }
324
- if ( m_innerEditor ) {
325
- var exportModelSettingsEditor = m_innerEditor as ExportModelSettingsEditor ;
326
- if ( exportModelSettingsEditor ) {
327
- exportModelSettingsEditor . DisableIncludeDropdown ( m_isTimelineAnim ) ;
328
- }
329
- }
330
- }
331
-
332
- private void SetSingleHierarchyExport ( bool singleHierarchy ) {
333
- m_singleHierarchyExport = singleHierarchy ;
334
-
335
- if ( m_innerEditor ) {
336
- var exportModelSettingsEditor = m_innerEditor as ExportModelSettingsEditor ;
337
- if ( exportModelSettingsEditor ) {
338
- exportModelSettingsEditor . SetIsSingleHierarchy ( m_singleHierarchyExport ) ;
339
- }
340
- }
341
- }
342
-
343
- private void SetIsPlayableDirector ( bool isPlayableDirector ) {
344
- m_isPlayableDirector = isPlayableDirector ;
345
- }
346
-
347
366
/// <summary>
348
367
/// Gets the filename from objects to export.
349
368
/// </summary>
@@ -364,16 +383,11 @@ protected override void OnEnable ()
364
383
base . OnEnable ( ) ;
365
384
if ( ! m_innerEditor ) {
366
385
m_innerEditor = UnityEditor . Editor . CreateEditor ( ExportSettings . instance . exportModelSettings ) ;
367
- this . SetSingleHierarchyExport ( m_singleHierarchyExport ) ;
368
- this . SetAnimationExportType ( m_isTimelineAnim ) ;
386
+ this . SingleHierarchyExport = m_singleHierarchyExport ;
387
+ this . IsTimelineAnim = m_isTimelineAnim ;
369
388
}
370
389
}
371
390
372
- protected override bool DisableNameSelection ( )
373
- {
374
- return m_isPlayableDirector ;
375
- }
376
-
377
391
protected override void Export ( ) {
378
392
var folderPath = ExportSettings . GetFbxAbsoluteSavePath ( ) ;
379
393
var filePath = System . IO . Path . Combine ( folderPath , m_exportFileName + ".fbx" ) ;
@@ -382,7 +396,7 @@ protected override void Export(){
382
396
return ;
383
397
}
384
398
385
- if ( m_isPlayableDirector ) {
399
+ if ( IsPlayableDirector ) {
386
400
foreach ( var obj in m_toExport ) {
387
401
var go = ModelExporter . GetGameObject ( obj ) ;
388
402
if ( ! go ) {
0 commit comments