static void Init() { #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX SketchfabExporter window = (SketchfabExporter)EditorWindow.GetWindow(typeof(SketchfabExporter)); window.titleContent.text = "Sketchfab"; window.Show(); #else // and error dialog if not standalone EditorUtility.DisplayDialog("Error", "Your build target must be set to standalone", "Okay"); #endif }
void export() { finished = false; Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab); if (selection.Length == 0) { EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "Okay :("); return; } if (param_token.Trim().Length == 0) { EditorUtility.DisplayDialog("Invalid token!", "Your Sketchfab API Token identifies yourself to Sketchfab. You can get this token at https://sketchfab.com/dashboard.", ""); return; } ArrayList meshList = new ArrayList(); for (int i = 0; i < selection.Length; i++) { Component[] meshfilter = selection[i].GetComponentsInChildren(typeof(MeshFilter)); for (int m = 0; m < meshfilter.Length; m++) { meshList.Add(meshfilter[m]); } Component[] skinnermeshrenderer = selection[i].GetComponentsInChildren(typeof(SkinnedMeshRenderer)); for (int m = 0; m < skinnermeshrenderer.Length; m++) { meshList.Add(skinnermeshrenderer[m]); } } if (meshList.Count > 0) { exporter = new SketchfabExporter(param_token, meshList, param_title, param_description, param_tags, param_private, param_password); exporter.export(); } else { EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "Okay :("); } }