MeshToolWrapper.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. internal class MeshToolWrapper : BaseTool
  6. {
  7. private MeshTool m_MeshTool;
  8. private SkeletonTool m_SkeletonTool;
  9. private SpriteMeshViewMode m_MeshMode;
  10. private bool m_Disable = false;
  11. private SkeletonMode m_SkeletonMode;
  12. protected MeshPreviewBehaviour m_MeshPreviewBehaviour = new MeshPreviewBehaviour();
  13. public MeshTool meshTool
  14. {
  15. get { return m_MeshTool; }
  16. set { m_MeshTool = value; }
  17. }
  18. public SkeletonTool skeletonTool
  19. {
  20. get { return m_SkeletonTool; }
  21. set { m_SkeletonTool = value; }
  22. }
  23. public SpriteMeshViewMode meshMode
  24. {
  25. get { return m_MeshMode; }
  26. set { m_MeshMode = value; }
  27. }
  28. public bool disableMeshEditor
  29. {
  30. get { return m_Disable; }
  31. set { m_Disable = value; }
  32. }
  33. public SkeletonMode skeletonMode
  34. {
  35. get { return m_SkeletonMode; }
  36. set { m_SkeletonMode = value; }
  37. }
  38. public override int defaultControlID
  39. {
  40. get
  41. {
  42. Debug.Assert(meshTool != null);
  43. return meshTool.defaultControlID;
  44. }
  45. }
  46. public override IMeshPreviewBehaviour previewBehaviour
  47. {
  48. get { return m_MeshPreviewBehaviour; }
  49. }
  50. protected override void OnActivate()
  51. {
  52. Debug.Assert(meshTool != null);
  53. skeletonTool.enableBoneInspector = false;
  54. skeletonTool.Activate();
  55. meshTool.Activate();
  56. m_MeshPreviewBehaviour.drawWireframe = true;
  57. m_MeshPreviewBehaviour.showWeightMap = false;
  58. m_MeshPreviewBehaviour.overlaySelected = false;
  59. }
  60. protected override void OnDeactivate()
  61. {
  62. skeletonTool.Deactivate();
  63. meshTool.Deactivate();
  64. }
  65. protected override void OnGUI()
  66. {
  67. DoSkeletonGUI();
  68. DoMeshGUI();
  69. }
  70. protected void DoSkeletonGUI()
  71. {
  72. Debug.Assert(skeletonTool != null);
  73. skeletonTool.mode = skeletonMode;
  74. skeletonTool.editBindPose = false;
  75. skeletonTool.DoGUI();
  76. }
  77. protected void DoMeshGUI()
  78. {
  79. Debug.Assert(meshTool != null);
  80. meshTool.disable = disableMeshEditor;
  81. meshTool.mode = meshMode;
  82. meshTool.DoGUI();
  83. }
  84. }
  85. }