File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed
Integrations/Autodesk/maya2017/scripts/unityOneClick Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -112,11 +112,24 @@ private static Object LoadModel (string fbxFileName)
112
112
return modelGO as Object ;
113
113
}
114
114
115
+ private static Bounds GetRendererBounds ( GameObject modelGO )
116
+ {
117
+ var renderers = modelGO . GetComponentsInChildren < Renderer > ( ) ;
118
+ if ( renderers . Length > 0 ) {
119
+ var bounds = renderers [ 0 ] . bounds ;
120
+ for ( int i = 1 ; i < renderers . Length ; i ++ ) {
121
+ bounds . Encapsulate ( renderers [ i ] . bounds ) ;
122
+ }
123
+ return bounds ;
124
+ }
125
+ return new Bounds ( ) ;
126
+ }
127
+
115
128
private static void FrameCameraOnModel ( GameObject modelGO )
116
129
{
117
130
// Set so camera frames model
118
131
// Note: this code assumes the model is at 0,0,0
119
- Vector3 boundsSize = modelGO . GetComponent < Renderer > ( ) . bounds . size ;
132
+ Vector3 boundsSize = GetRendererBounds ( modelGO ) . size ;
120
133
float distance = Mathf . Max ( boundsSize . x , boundsSize . y , boundsSize . z ) ;
121
134
distance /= ( 2.0f * Mathf . Tan ( 0.5f * Camera . main . fieldOfView * Mathf . Deg2Rad ) ) ;
122
135
Camera . main . transform . position = new Vector3 ( Camera . main . transform . position . x , Camera . main . transform . position . y , - distance * 2.0f ) ;
Original file line number Diff line number Diff line change @@ -222,12 +222,19 @@ def doIt(self, args):
222
222
return
223
223
224
224
# make sure the GamePipeline and fbxmaya plugins are loaded
225
- if self .loadDependencies ():
226
- # save fbx to Assets/_safe_to_delete/
227
- savePath = unityTempSavePath
228
- maya .cmds .sysFile (savePath , makeDir = True )
229
- savePath = savePath + "/TurnTableModel.fbx"
230
- maya .mel .eval (r'file -force -options "" -typ "FBX export" -pr -es "{0}"' .format (savePath ));
225
+ if not self .loadDependencies ():
226
+ return
227
+
228
+ # select the export set for export, if it exists,
229
+ # otherwise take what is currently selected
230
+ if self .setExists (self ._exportSet ):
231
+ maya .cmds .select (self ._exportSet , r = True , ne = True )
232
+
233
+ # save fbx to Assets/_safe_to_delete/
234
+ savePath = unityTempSavePath
235
+ maya .cmds .sysFile (savePath , makeDir = True )
236
+ savePath = savePath + "/TurnTableModel.fbx"
237
+ maya .mel .eval (r'file -force -options "" -typ "FBX export" -pr -es "{0}"' .format (savePath ));
231
238
232
239
if maya .cmds .about (macOS = True ):
233
240
# Use 'open -a' to bring app to front if it has already been started.
You can’t perform that action at this time.
0 commit comments