Пример #1
0
        public override void Start()
        {
            base.Start();

            // Just in case the order isn't guaranteed, I'm going to save the selecteds.
            selected       = Selection.GetTransforms(SelectionMode.TopLevel);
            avgPos         = Vector3.zero;
            originalScales = new Vector3[selected.Length];
            state.Init();
            state.onlyLocal = true;

            for (int i = 0; i < selected.Length; i++)
            {
                avgPos           += selected[i].position;
                originalScales[i] = selected[i].localScale;
            }

            avgPos /= selected.Length;

            Vector2 avgInSP = SceneView.lastActiveSceneView.camera.WorldToScreenPoint(avgPos);

            avgInSP.y       = SceneView.lastActiveSceneView.camera.pixelHeight - avgInSP.y;
            orignalDistance = Vector2.Distance(Event.current.mousePosition, avgInSP);

            if (orignalDistance == 0)
            {
                orignalDistance = 0.1f;
            }

            Undo.IncrementCurrentGroup();
        }
Пример #2
0
        public override void Start()
        {
            base.Start();

            originalMousePos   = Event.current.mousePosition;
            originalMousePos.y = SceneView.lastActiveSceneView.camera.pixelHeight - originalMousePos.y;

            // Just in case the order isn't guaranteed, I'm going to save the selecteds.
            selected              = Selection.GetTransforms(SelectionMode.TopLevel);
            toObjects             = new Vector3[selected.Length];
            lastKnownGoodLocalPos = new Vector3[selected.Length];
            originalAvgPos        = Vector3.zero;
            state.Init();

            for (int i = 0; i < selected.Length; i++)
            {
                originalAvgPos          += selected[i].position;
                lastKnownGoodLocalPos[i] = selected[i].position;
            }

            originalAvgPos  /= selected.Length;
            lastKnownGoodPos = originalAvgPos;

            // Now that we have the average position, we get a bunch of vectors to each objects.
            for (int i = 0; i < selected.Length; i++)
            {
                toObjects[i] = selected[i].position - originalAvgPos;
            }

            Undo.IncrementCurrentGroup();
        }
Пример #3
0
        public override void Start()
        {
            base.Start();

            originalMousePos = Event.current.mousePosition;

            // Just in case the order isn't guaranteed, I'm going to save the selecteds.
            selected          = Selection.GetTransforms(SelectionMode.TopLevel);
            avgPos            = Vector3.zero;
            originalRotations = new Vector3[selected.Length];
            originalPositions = new Vector3[selected.Length];
            state.Init();

            for (int i = 0; i < selected.Length; i++)
            {
                avgPos += selected[i].position;
                originalRotations[i] = selected[i].eulerAngles;
                originalPositions[i] = selected[i].position;
            }

            avgPos /= selected.Length;

            Undo.IncrementCurrentGroup();
        }