public void DoSlope(bool oriented)
        {
            var maxObjects = VertexUtils.OutmostPoints(selection.ToArray());

            float      heightDiff    = maxObjects.Value.m_position.y - maxObjects.Key.m_position.y;
            float      distDiff      = Vector2.Distance(maxObjects.Value.m_position.AsXZVector2(), maxObjects.Key.m_position.AsXZVector2());
            Vector3    flatDirection = new Vector3(maxObjects.Value.m_position.x, 0, maxObjects.Value.m_position.z) - new Vector3(maxObjects.Key.m_position.x, 0, maxObjects.Key.m_position.z);
            Quaternion rotDiff       = Quaternion.FromToRotation(flatDirection, maxObjects.Value.m_position - maxObjects.Key.m_position);

            foreach (var po in selection)
            {
                var localdistdiff   = Vector3.Project((po.m_position - maxObjects.Key.m_position).NullY(), (maxObjects.Value.m_position - maxObjects.Key.m_position).NullY()).magnitude;
                var localheightdiff = (po == maxObjects.Key) ? 0f : ((po == maxObjects.Value) ? heightDiff : heightDiff * localdistdiff / distDiff);
                if (po.isRootOfGroup && logic.selectedGroup == null)
                {
                    foreach (var o in po.group.objects)
                    {
                        if (oriented)
                        {
                            o.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.moveTo, null);
                            o.SetPosition(new Vector3(o.m_position.x, localheightdiff + maxObjects.Key.m_position.y, o.m_position.z));
                            o.SetRotation(rotDiff * o.m_rotation);
                            if (o != po)
                            {
                                o.m_position = VertexUtils.RotatePointAroundPivot(o.m_position, po.m_position, rotDiff);
                            }
                        }
                        else
                        {
                            o.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.position, null);
                            o.SetPosition(new Vector3(o.m_position.x, localheightdiff + maxObjects.Key.m_position.y, o.m_position.z));
                        }
                        o.historyEditionBuffer.ConfirmNewStep(null);
                    }
                }
                else
                {
                    if (oriented)
                    {
                        po.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.moveTo, null);
                        po.SetRotation(rotDiff * po.m_rotation);
                    }
                    else
                    {
                        po.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.position, null);
                    }
                    po.SetPosition(new Vector3(po.m_position.x, localheightdiff + maxObjects.Key.m_position.y, po.m_position.z));
                    po.historyEditionBuffer.ConfirmNewStep(null);
                }
            }
        }
 public override void OnOpen(List <ProceduralObject> selection)
 {
     confirmed      = false;
     this.selection = POGroup.AllObjectsInSelection(selection, logic.selectedGroup);
     if (this.selection.Count < 2)
     {
         ExitAction();
         return;
     }
     oldColors = new Dictionary <ProceduralObject, Color>();
     foreach (var obj in this.selection)
     {
         oldColors.Add(obj, obj.m_color);
     }
     gradientTex = TextureUtils.PlainTexture(100, 22, Color.white);
     maxObjects  = VertexUtils.OutmostPoints(this.selection.ToArray());
     gradient    = new Gradient();
 }