Exemple #1
0
 // Draw scale handle
 private void ScaleHandle(int index, Vector3 position)
 {
     if (tool == 0)   //Simple 1D scale tool in edit mode
     {
         EditorGUI.BeginChangeCheck();
         Quaternion rotation = component.GetRotation(activeSpline, index);
         float      scale    = component.GetHandleMagnitude(activeSpline, index, 1);
         Handles.color = new Color(.4f, .4f, .8f);
         scale         = Handles.ScaleSlider(scale, position, rotation * Vector3.forward, rotation, HandleUtility.GetHandleSize(position), 0f);
         if (EditorGUI.EndChangeCheck())
         {
             Undo.RecordObject(component, "Scale Point");
             EditorUtility.SetDirty(component);
             float scale2 = scale / component.GetHandleMagnitude(activeSpline, index, 1) * component.GetHandleMagnitude(activeSpline, index, 0);
             component.SetHandleMagnitude(activeSpline, index, 1, scale);
             component.SetHandleMagnitude(activeSpline, index, 0, scale2);
         }
     }
     else   //Full scale tool in junction mode
     {
         EditorGUI.BeginChangeCheck();
         Quaternion rotation = Quaternion.identity;
         float      scale    = component.GetHandleMagnitude(activeSpline, index, 1);
         Vector3    scale3D  = scale * Vector3.one;
         Handles.color = new Color(.4f, .4f, .8f);
         scale3D       = Handles.ScaleHandle(scale3D, position, rotation, HandleUtility.GetHandleSize(position));
         if (EditorGUI.EndChangeCheck())
         {
             Undo.RecordObject(component, "Scale Point");
             EditorUtility.SetDirty(component);
             component.ScaleConnection(activeSpline, index, scale3D / scale);
         }
     }
 }