JointInspector.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using bs;
  4. namespace bs.Editor
  5. {
  6. /** @addtogroup Inspectors
  7. * @{
  8. */
  9. /// <summary>
  10. /// Renders common inspector elements for all <see cref="Joint"/> components.
  11. /// </summary>
  12. internal abstract class JointInspector : Inspector
  13. {
  14. /// <summary>
  15. /// Creates GUI elements for fields common to all joints.
  16. /// </summary>
  17. protected virtual void BuildGUI(Joint joint, bool showOffsets)
  18. {
  19. drawer.AddField("Target", () => joint.GetBody(JointBody.Target), x => joint.SetBody(JointBody.Target, x));
  20. drawer.AddField("Anchor", () => joint.GetBody(JointBody.Anchor), x => joint.SetBody(JointBody.Anchor, x));
  21. if (showOffsets)
  22. {
  23. drawer.AddField("Target offset",
  24. () => joint.GetPosition(JointBody.Target),
  25. x => joint.SetTransform(JointBody.Target, x, joint.GetRotation(JointBody.Target)));
  26. drawer.AddField("Anchor offset",
  27. () => joint.GetPosition(JointBody.Anchor),
  28. x => joint.SetTransform(JointBody.Anchor, x, joint.GetRotation(JointBody.Anchor)));
  29. }
  30. drawer.AddDefault(joint, typeof(Joint));
  31. }
  32. }
  33. /** @} */
  34. }