DaeExporterWindow.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System;
  4. using System.Collections;
  5. namespace VoxelImporter
  6. {
  7. public class DaeExporterWindow : EditorWindow
  8. {
  9. public static DaeExporterWindow instance { get; private set; }
  10. public static bool exportMesh = true;
  11. public static bool exportAnimation = true;
  12. public static bool enableFootIK = true;
  13. private static bool human;
  14. private static Action onExport;
  15. public static void Open(bool human, Action onExport)
  16. {
  17. DaeExporterWindow.human = human;
  18. DaeExporterWindow.onExport = onExport;
  19. if (instance == null)
  20. {
  21. instance = CreateInstance<DaeExporterWindow>();
  22. }
  23. instance.titleContent = new GUIContent("Collada Exporter");
  24. instance.minSize = instance.maxSize = new Vector2(180, 80);
  25. instance.ShowAuxWindow();
  26. }
  27. void OnGUI()
  28. {
  29. {
  30. EditorGUI.BeginChangeCheck();
  31. var flag = EditorGUILayout.Toggle("Export Mesh", exportMesh);
  32. if (EditorGUI.EndChangeCheck())
  33. {
  34. exportMesh = flag;
  35. }
  36. }
  37. {
  38. EditorGUI.BeginChangeCheck();
  39. var flag = EditorGUILayout.Toggle("Export Animation", exportAnimation);
  40. if (EditorGUI.EndChangeCheck())
  41. {
  42. exportAnimation = flag;
  43. }
  44. }
  45. if (human)
  46. {
  47. EditorGUI.indentLevel++;
  48. EditorGUI.BeginDisabledGroup(!exportAnimation);
  49. EditorGUI.BeginChangeCheck();
  50. var flag = EditorGUILayout.Toggle(new GUIContent("Foot IK", "Activates feet IK bake."), enableFootIK);
  51. if (EditorGUI.EndChangeCheck())
  52. {
  53. enableFootIK = flag;
  54. }
  55. EditorGUI.EndDisabledGroup();
  56. EditorGUI.indentLevel--;
  57. }
  58. {
  59. EditorGUILayout.BeginHorizontal();
  60. EditorGUILayout.Space();
  61. if (GUILayout.Button("Export"))
  62. {
  63. EditorApplication.delayCall += () =>
  64. {
  65. if (onExport != null)
  66. onExport.Invoke();
  67. onExport = null;
  68. };
  69. Close();
  70. }
  71. EditorGUILayout.Space();
  72. EditorGUILayout.EndHorizontal();
  73. }
  74. if (Event.current.keyCode == KeyCode.Escape)
  75. {
  76. Close();
  77. return;
  78. }
  79. }
  80. }
  81. }