@@ -46,6 +46,14 @@ public abstract class ExportOptionsEditorWindow : EditorWindow
46
46
protected GUIStyle m_fbxExtLabelStyle ;
47
47
protected float m_fbxExtLabelWidth ;
48
48
49
+ protected abstract EditorTools . ExportOptionsSettingsSerializeBase SettingsObject { get ; }
50
+
51
+ private UnityEngine . Object [ ] m_toExport ;
52
+ protected UnityEngine . Object [ ] ToExport {
53
+ get { return m_toExport ; }
54
+ set { m_toExport = value ; }
55
+ }
56
+
49
57
protected virtual void OnEnable ( ) {
50
58
InitializeReceiver ( ) ;
51
59
m_showOptions = true ;
@@ -120,8 +128,31 @@ protected void ShowPresetReceiver(UnityEngine.Object target){
120
128
UnityEditor . Presets . PresetSelector . ShowSelector ( target , null , true , m_receiver ) ;
121
129
}
122
130
123
- protected abstract Transform TransferAnimationSource { get ; set ; }
124
- protected abstract Transform TransferAnimationDest { get ; set ; }
131
+ protected Transform TransferAnimationSource {
132
+ get {
133
+ return SettingsObject . AnimationSource ;
134
+ }
135
+ set {
136
+ var selectedGO = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
137
+ if ( ! TransferAnimationSourceIsValid ( value , selectedGO ) ) {
138
+ return ;
139
+ }
140
+ SettingsObject . SetAnimationSource ( value ) ;
141
+ }
142
+ }
143
+
144
+ protected Transform TransferAnimationDest {
145
+ get {
146
+ return SettingsObject . AnimationDest ;
147
+ }
148
+ set {
149
+ var selectedGO = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
150
+ if ( ! TransferAnimationDestIsValid ( value , selectedGO ) ) {
151
+ return ;
152
+ }
153
+ SettingsObject . SetAnimationDest ( value ) ;
154
+ }
155
+ }
125
156
126
157
//-------Helper functions for determining if Animation source and dest are valid---------
127
158
@@ -153,7 +184,7 @@ protected bool IsInSameHierarchy(Transform t1, Transform t2){
153
184
}
154
185
155
186
156
- protected virtual bool TransferAnimationSourceIsValid ( Transform newValue , GameObject selectedGO ) {
187
+ protected bool TransferAnimationSourceIsValid ( Transform newValue , GameObject selectedGO ) {
157
188
if ( ! newValue ) {
158
189
return true ;
159
190
}
@@ -171,7 +202,7 @@ protected virtual bool TransferAnimationSourceIsValid(Transform newValue, GameOb
171
202
return true ;
172
203
}
173
204
174
- protected virtual bool TransferAnimationDestIsValid ( Transform newValue , GameObject selectedGO ) {
205
+ protected bool TransferAnimationDestIsValid ( Transform newValue , GameObject selectedGO ) {
175
206
if ( ! newValue ) {
176
207
return true ;
177
208
}
@@ -336,7 +367,6 @@ protected bool OverwriteExistingFile(string filePath){
336
367
public class ExportModelEditorWindow : ExportOptionsEditorWindow
337
368
{
338
369
protected override float MinWindowHeight { get { return 260 ; } }
339
- private UnityEngine . Object [ ] m_toExport ;
340
370
341
371
private bool m_isTimelineAnim = false ;
342
372
protected bool IsTimelineAnim {
@@ -380,30 +410,9 @@ protected bool IsPlayableDirector {
380
410
}
381
411
}
382
412
383
- protected override Transform TransferAnimationSource {
384
- get {
385
- return ExportSettings . instance . exportModelSettings . info . AnimationSource ;
386
- }
387
- set {
388
- var selectedGO = ModelExporter . GetGameObject ( m_toExport [ 0 ] ) ;
389
- if ( ! TransferAnimationSourceIsValid ( value , selectedGO ) ) {
390
- return ;
391
- }
392
- ExportSettings . instance . exportModelSettings . info . SetAnimationSource ( value ) ;
393
- }
394
- }
395
-
396
- protected override Transform TransferAnimationDest {
397
- get {
398
- return ExportSettings . instance . exportModelSettings . info . AnimationDest ;
399
- }
400
- set {
401
- var selectedGO = ModelExporter . GetGameObject ( m_toExport [ 0 ] ) ;
402
- if ( ! TransferAnimationDestIsValid ( value , selectedGO ) ) {
403
- return ;
404
- }
405
- ExportSettings . instance . exportModelSettings . info . SetAnimationDest ( value ) ;
406
- }
413
+ protected override ExportOptionsSettingsSerializeBase SettingsObject
414
+ {
415
+ get { return ExportSettings . instance . exportModelSettings . info ; }
407
416
}
408
417
409
418
public static void Init ( IEnumerable < UnityEngine . Object > toExport , string filename = "" , bool isTimelineAnim = false , bool isPlayableDirector = false )
@@ -421,19 +430,19 @@ public static void Init (IEnumerable<UnityEngine.Object> toExport, string filena
421
430
}
422
431
423
432
protected int SetGameObjectsToExport ( IEnumerable < UnityEngine . Object > toExport ) {
424
- m_toExport = toExport . ToArray ( ) ;
433
+ ToExport = toExport . ToArray ( ) ;
425
434
426
435
// if only one object selected, set transfer source/dest to this object
427
- if ( m_toExport . Length == 1 ) {
428
- var go = ModelExporter . GetGameObject ( m_toExport [ 0 ] ) ;
436
+ if ( ToExport . Length == 1 ) {
437
+ var go = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
429
438
if ( go ) {
430
439
TransferAnimationSource = go . transform ;
431
440
TransferAnimationDest = go . transform ;
432
441
}
433
442
}
434
- DisableTransferAnim = m_toExport . Length > 1 ;
443
+ DisableTransferAnim = ToExport . Length > 1 ;
435
444
436
- return m_toExport . Length ;
445
+ return ToExport . Length ;
437
446
}
438
447
439
448
/// <summary>
@@ -443,8 +452,8 @@ protected int SetGameObjectsToExport(IEnumerable<UnityEngine.Object> toExport){
443
452
/// objects selected for export.</returns>
444
453
protected string GetFilenameFromObjects ( ) {
445
454
var filename = "" ;
446
- if ( m_toExport . Length == 1 ) {
447
- filename = m_toExport [ 0 ] . name ;
455
+ if ( ToExport . Length == 1 ) {
456
+ filename = ToExport [ 0 ] . name ;
448
457
} else {
449
458
filename = "Untitled" ;
450
459
}
@@ -470,20 +479,20 @@ protected override void Export(){
470
479
}
471
480
472
481
if ( IsPlayableDirector ) {
473
- foreach ( var obj in m_toExport ) {
482
+ foreach ( var obj in ToExport ) {
474
483
var go = ModelExporter . GetGameObject ( obj ) ;
475
484
if ( ! go ) {
476
485
continue ;
477
486
}
478
- ModelExporter . ExportAllTimelineClips ( go , folderPath , ExportSettings . instance . exportModelSettings . info ) ;
487
+ ModelExporter . ExportAllTimelineClips ( go , folderPath , SettingsObject ) ;
479
488
}
480
489
// refresh the asset database so that the file appears in the
481
490
// asset folder view.
482
491
AssetDatabase . Refresh ( ) ;
483
492
return ;
484
493
}
485
494
486
- if ( ModelExporter . ExportObjects ( filePath , m_toExport , ExportSettings . instance . exportModelSettings . info , timelineAnim : m_isTimelineAnim ) != null ) {
495
+ if ( ModelExporter . ExportObjects ( filePath , ToExport , SettingsObject , timelineAnim : m_isTimelineAnim ) != null ) {
487
496
// refresh the asset database so that the file appears in the
488
497
// asset folder view.
489
498
AssetDatabase . Refresh ( ) ;
0 commit comments