Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert Control Points Before/After Toolbar
#1
Hi,
Here is my two cents on a handy usability feature when editing Control Points: Insert After & Insert Before toolbar shortcuts.

Here is what I added to CurvyToolbar.cs to enables this:

Code:
   [ToolbarItem(107, "Curvy", "Insert After", "Adds a control point after ", "next,24,24")]
   public class TBCPAppend : DTToolbarButton
   {
       public override string StatusBarInfo { get { return "Insert point after the current one"; } }

       public TBCPAppend()
       {
           KeyBindings.Add(new EditorKeyBinding("Insert", "", KeyCode.Insert));
       }

       public override void OnClick()
       {
           base.OnClick();
           CurvySplineSegment point = DTSelection.GetAs<CurvySplineSegment>(false);
           if (point)
           {
               point = point.Spline.InsertAfter(point);
               Selection.activeGameObject = point.gameObject;
           }
       }

       public override void OnSelectionChange()
       {
           Visible = DTSelection.HasComponent<CurvySplineSegment>();
       }
   }
   
   [ToolbarItem(107, "Curvy", "Insert Before", "Adds a control point before ", "prev,24,24")]
   public class TBCPInsertBefore : DTToolbarButton
   {
       public override string StatusBarInfo { get { return "Insert point before the selected one"; } }

       public TBCPInsertBefore()
       {
           KeyBindings.Add(new EditorKeyBinding("Insert before", "", KeyCode.Insert, true));
       }

       public override void OnClick()
       {
           base.OnClick();
           CurvySplineSegment point = DTSelection.GetAs<CurvySplineSegment>(false);
           if (point)
           {
               point = point.Spline.InsertBefore(point);
               Selection.activeGameObject = point.gameObject;
           }
       }

       public override void OnSelectionChange()
       {
           Visible = DTSelection.HasComponent<CurvySplineSegment>();
       }
   }

Just those few things missing:
  • Appropriate icons
  • Insert before shortcut does not seem to work...
Reply
#2
You can add your own icons to packages/curvy/base/editor/resources, then set them in the class attribute (e.g. replace "prev,24,24" with "myicon,24,24").

The problem with keycodes is that lots of them are used by Unity and there is no reliable way of overriding them.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Scene 51: Dynamic track between two points wallflower6 3 8 08-19-2024, 08:18 AM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 9 03-28-2024, 10:08 PM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_

Forum Jump: