private void bgwS2AOutput_DoWork(object sender, DoWorkEventArgs e) { ConvertAlgorithm C = new ConvertAlgorithm(); int fileNum = lvSrtFileSelection.Items.Count; string[] scriptInfo = new string[0]; string[] v4Style = new string[0]; string events = ""; string engStyle = ""; ssProgressBar.Maximum = fileNum; ssProgressBar.Minimum = 0; ssProgressBar.Step = 1; ssProgressBar.Value = 0; try { if (lvSrtFileSelection.Items.Count == 0) { throw new Exception("请选择源文件"); } if (tbASSOutputFolder.Text == "") { throw new Exception("请选择目标文件夹"); } if (cbEffCfg.Text == "") { throw new Exception("请选择特效"); } ReadEffectDetail(cbEffCfg.Text, ref scriptInfo, ref v4Style, ref events, ref engStyle); S2AControlEnable(false); foreach (ListViewItem lviFile in lvSrtFileSelection.Items) { string file = lviFile.Tag as string; C.Entry(file, tbASSOutputFolder.Text, scriptInfo, v4Style, engStyle, events); ssProgressBar.PerformStep(); } S2AControlEnable(true); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void OnGUI() { #if UNITY_5_0 #else this.titleContent.text = "New Voxel Structure"; #endif EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Converter settings", EditorStyles.boldLabel); this.objectToConvert = (GameObject)EditorGUILayout.ObjectField("Object to Convert", this.objectToConvert, typeof(GameObject), true); EditorGUILayout.Space(); selectedAlgorithm = (ConvertAlgorithm)EditorGUILayout.Popup("Algorithm", (int)selectedAlgorithm, algorithmOptions); this.isRecursive = GUILayout.Toggle(this.isRecursive, "Convert child object"); this.colorTolerance = EditorGUILayout.Slider("Color tolerance", this.colorTolerance, 0, 100); EditorGUILayout.Space(); if (GUILayout.Button("Convert")) { if (this.objectToConvert != null) { if (GameObject.Find(this.objectToConvert.name) == null) { EditorUtility.DisplayDialog("Warning", "Please add the object to the scene before converting.", "Ok"); } else { this.ConvertObject(this.objectToConvert); } } } EditorGUILayout.EndVertical(); if ((this.objectToConvert != null) && (this.objectToConvert.GetComponent <MeshCollider>() != null)) { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical("Box"); MeshCollider meshCollider = this.objectToConvert.GetComponent <MeshCollider>(); EditorGUILayout.HelpBox("This current model with it's current scale will be about " + System.Environment.NewLine + ((int)meshCollider.bounds.size.x) + "X" + ((int)meshCollider.bounds.size.y) + "X" + ((int)meshCollider.bounds.size.z) + " voxel wide." + System.Environment.NewLine + "Please rescale the object if it does not fit your expectations.", MessageType.Info); EditorGUILayout.EndVertical(); } else { EditorGUILayout.Space(); EditorGUILayout.Space(); } EditorGUILayout.BeginVertical("Box"); if (GUILayout.Button("Tutorial")) { Process myProcess = new Process(); try { myProcess.StartInfo.UseShellExecute = true; myProcess.StartInfo.FileName = "https://www.youtube.com/watch?v=11ckLazjsOY"; myProcess.Start(); } catch (Exception e) { UnityEngine.Debug.LogError("Could not open webpage: " + e.Message); } } EditorGUILayout.HelpBox("You can scale the orignal model to obtain the required resolution." + System.Environment.NewLine + System.Environment.NewLine + "Also please make sure you have a mesh collider in your source object!" + System.Environment.NewLine + "And the object to convert, is have to be part of the scene!", MessageType.Info); EditorGUILayout.EndVertical(); }