DragPointOther.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. namespace COM3D2.MeidoPhotoStudio.Plugin
  5. {
  6. public class DragPointBody : DragPointGeneral
  7. {
  8. public bool IsCube;
  9. private bool isIK;
  10. public bool IsIK
  11. {
  12. get => isIK;
  13. set
  14. {
  15. if (isIK != value)
  16. {
  17. isIK = value;
  18. ApplyDragType();
  19. }
  20. }
  21. }
  22. protected override void ApplyDragType()
  23. {
  24. bool enabled = !IsIK && (Transforming || Selecting);
  25. bool select = IsIK && Selecting;
  26. ApplyProperties(enabled || select, IsCube && enabled, false);
  27. if (IsCube) ApplyColours();
  28. }
  29. }
  30. public class DragPointBG : DragPointGeneral
  31. {
  32. public override void Set(Transform myObject)
  33. {
  34. base.Set(myObject);
  35. DefaultPosition = myObject.position;
  36. }
  37. protected override void ApplyDragType()
  38. {
  39. ApplyProperties(Transforming, Transforming, Rotating);
  40. ApplyColours();
  41. }
  42. }
  43. public class DragPointDogu : DragPointGeneral
  44. {
  45. private List<Renderer> meshRenderers;
  46. public AttachPointInfo attachPointInfo = AttachPointInfo.Empty;
  47. public string Name => MyGameObject.name;
  48. public string assetName = string.Empty;
  49. public bool ShadowCasting
  50. {
  51. get
  52. {
  53. if (meshRenderers.Count == 0) return false;
  54. return meshRenderers[0].shadowCastingMode == ShadowCastingMode.On;
  55. }
  56. set
  57. {
  58. foreach (Renderer renderer in meshRenderers)
  59. {
  60. renderer.shadowCastingMode = value ? ShadowCastingMode.On : ShadowCastingMode.Off;
  61. }
  62. }
  63. }
  64. public override void Set(Transform myObject)
  65. {
  66. base.Set(myObject);
  67. DefaultRotation = MyObject.rotation;
  68. DefaultPosition = MyObject.position;
  69. meshRenderers = new List<Renderer>(MyObject.GetComponentsInChildren<SkinnedMeshRenderer>());
  70. meshRenderers.AddRange(MyObject.GetComponentsInChildren<MeshRenderer>());
  71. }
  72. protected override void ApplyDragType()
  73. {
  74. bool active = (DragPointEnabled && Transforming) || Special;
  75. ApplyProperties(active, active, GizmoEnabled && Rotating);
  76. ApplyColours();
  77. }
  78. protected override void OnDestroy()
  79. {
  80. GameObject.Destroy(MyGameObject);
  81. base.OnDestroy();
  82. }
  83. }
  84. }