DragPointOther.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. protected override void ApplyDragType()
  33. {
  34. ApplyProperties(Transforming, Transforming, Rotating);
  35. ApplyColours();
  36. }
  37. }
  38. public class DragPointDogu : DragPointGeneral
  39. {
  40. private List<Renderer> meshRenderers;
  41. public AttachPointInfo attachPointInfo = AttachPointInfo.Empty;
  42. public string Name => MyGameObject.name;
  43. public string assetName = string.Empty;
  44. public bool ShadowCasting
  45. {
  46. get
  47. {
  48. if (meshRenderers.Count == 0) return false;
  49. return meshRenderers[0].shadowCastingMode == ShadowCastingMode.On;
  50. }
  51. set
  52. {
  53. foreach (Renderer renderer in meshRenderers)
  54. {
  55. renderer.shadowCastingMode = value ? ShadowCastingMode.On : ShadowCastingMode.Off;
  56. }
  57. }
  58. }
  59. public override void Set(Transform myObject)
  60. {
  61. base.Set(myObject);
  62. DefaultRotation = MyObject.rotation;
  63. DefaultPosition = MyObject.position;
  64. meshRenderers = new List<Renderer>(MyObject.GetComponentsInChildren<SkinnedMeshRenderer>());
  65. meshRenderers.AddRange(MyObject.GetComponentsInChildren<MeshRenderer>());
  66. }
  67. protected override void ApplyDragType()
  68. {
  69. bool active = (DragPointEnabled && Transforming) || Special;
  70. ApplyProperties(active, active, GizmoEnabled && Rotating);
  71. ApplyColours();
  72. }
  73. protected override void OnDestroy()
  74. {
  75. GameObject.Destroy(MyGameObject);
  76. base.OnDestroy();
  77. }
  78. }
  79. }