コード例 #1
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;
                _LastKnownGoodPos = _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();
        }
コード例 #2
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();
        }
コード例 #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();
        }