Exemple #1
0
 public override void OnGizmoDragEnd(int handleId)
 {
     if (OwnsHandle(handleId))
     {
         if (BoxUsage == Usage.ObjectScale && _targetHierarchyTransform != null)
         {
             var postSnapshot = new LocalTransformSnapshot();
             postSnapshot.Snapshot(_targetHierarchyTransform);
             var action = new PostObjectTransformsChangedAction(new List <LocalTransformSnapshot>()
             {
                 _dragBeginTargetTransformSnapshot
             },
                                                                new List <LocalTransformSnapshot>()
             {
                 postSnapshot
             });
             action.Execute();
         }
     }
 }
Exemple #2
0
        public static List <LocalTransformSnapshot> GetSnapshotCollection(IEnumerable <GameObject> gameObjects)
        {
            if (gameObjects == null)
            {
                return(new List <LocalTransformSnapshot>());
            }

            List <LocalTransformSnapshot> localTransformSnapshots = new List <LocalTransformSnapshot>(20);

            foreach (GameObject gameObject in gameObjects)
            {
                if (gameObject != null)
                {
                    LocalTransformSnapshot snapshot = new LocalTransformSnapshot();
                    snapshot.Snapshot(gameObject.transform);
                    localTransformSnapshots.Add(snapshot);
                }
            }

            return(localTransformSnapshots);
        }
Exemple #3
0
        public override void OnGizmoAttemptHandleDragBegin(int handleId)
        {
            if (OwnsHandle(handleId))
            {
                _scaleFromCenter = Hotkeys.EnableCenterPivot.IsActive();
                _scaleDragWorkData.DragOrigin = BoxCenter;

                if (handleId == _leftTick.HandleId)
                {
                    _scaleDragWorkData.Axis        = -BoxRight;
                    _scaleDragWorkData.AxisIndex   = 0;
                    _scaleDragWorkData.SnapStep    = Settings3D.XSnapStep;
                    _scaleDragWorkData.EntityScale = _targetHierarchyTransform.lossyScale.x;
                    _scalePivot = BoxMath.CalcBoxFaceCenter(BoxCenter, _boxSize, BoxRotation, BoxFace.Right);
                }
                else
                if (handleId == _rightTick.HandleId)
                {
                    _scaleDragWorkData.Axis        = BoxRight;
                    _scaleDragWorkData.AxisIndex   = 0;
                    _scaleDragWorkData.SnapStep    = Settings3D.XSnapStep;
                    _scaleDragWorkData.EntityScale = _targetHierarchyTransform.lossyScale.x;
                    _scalePivot = BoxMath.CalcBoxFaceCenter(BoxCenter, _boxSize, BoxRotation, BoxFace.Left);
                }
                else
                if (handleId == _topTick.HandleId)
                {
                    _scaleDragWorkData.Axis        = BoxUp;
                    _scaleDragWorkData.AxisIndex   = 1;
                    _scaleDragWorkData.SnapStep    = Settings3D.YSnapStep;
                    _scaleDragWorkData.EntityScale = _targetHierarchyTransform.lossyScale.y;
                    _scalePivot = BoxMath.CalcBoxFaceCenter(BoxCenter, _boxSize, BoxRotation, BoxFace.Bottom);
                }
                else
                if (handleId == _bottomTick.HandleId)
                {
                    _scaleDragWorkData.Axis        = -BoxUp;
                    _scaleDragWorkData.AxisIndex   = 1;
                    _scaleDragWorkData.SnapStep    = Settings3D.YSnapStep;
                    _scaleDragWorkData.EntityScale = _targetHierarchyTransform.lossyScale.y;
                    _scalePivot = BoxMath.CalcBoxFaceCenter(BoxCenter, _boxSize, BoxRotation, BoxFace.Top);
                }
                else
                if (handleId == _frontTick.HandleId)
                {
                    _scaleDragWorkData.Axis        = -BoxLook;
                    _scaleDragWorkData.AxisIndex   = 2;
                    _scaleDragWorkData.SnapStep    = Settings3D.ZSnapStep;
                    _scaleDragWorkData.EntityScale = _targetHierarchyTransform.lossyScale.z;
                    _scalePivot = BoxMath.CalcBoxFaceCenter(BoxCenter, _boxSize, BoxRotation, BoxFace.Back);
                }
                else
                if (handleId == _backTick.HandleId)
                {
                    _scaleDragWorkData.Axis        = BoxLook;
                    _scaleDragWorkData.AxisIndex   = 2;
                    _scaleDragWorkData.SnapStep    = Settings3D.ZSnapStep;
                    _scaleDragWorkData.EntityScale = _targetHierarchyTransform.lossyScale.z;
                    _scalePivot = BoxMath.CalcBoxFaceCenter(BoxCenter, _boxSize, BoxRotation, BoxFace.Front);
                }

                if (_scaleFromCenter)
                {
                    _scalePivot = BoxCenter;
                }
                _scaleDrag.SetWorkData(_scaleDragWorkData);

                if (BoxUsage == Usage.ObjectScale && _targetHierarchyTransform != null)
                {
                    _dragBeginTargetTransformSnapshot.Snapshot(_targetHierarchyTransform);
                }
            }
        }