示例#1
0
        private bool Begin(IEnumerable <GameObject> targetObjects)
        {
            if (_state != State.Inactive || SharedSettings == null || SharedHotkeys == null || targetObjects == null)
            {
                return(false);
            }

            _targetObjects = new List <GameObject>(targetObjects);
            if (_targetObjects.Count == 0)
            {
                return(false);
            }
            _targetParents = GameObjectEx.FilterParentsOnly(_targetObjects);

            if (!CalculateTargetAABB() || !IdentifySitSurface())
            {
                _targetObjects.Clear();
                _targetParents.Clear();
                return(false);
            }

            _state = State.Active;
            _preTargetTransformSnapshots = LocalTransformSnapshot.GetSnapshotCollection(_targetParents);

            if (SessionBegin != null)
            {
                SessionBegin();
            }
            return(true);
        }
        private bool Begin(IEnumerable <GameObject> targetObjects)
        {
            if (_state != State.Inactive || SharedSettings == null || _sharedHotkeys == null || targetObjects == null)
            {
                return(false);
            }
            if ((int)SharedSettings.SurfaceFlags == 0)
            {
                return(false);
            }

            if (!IdentifyGrabTargets(targetObjects))
            {
                return(false);
            }
            if (!IdentifyGrabSurface())
            {
                _grabTargets.Clear();
                return(false);
            }
            CalculateGrabTargetsAnchorVectors();

            _state = State.ActiveSnapToSurface;
            _preTargetTransformSnapshots = LocalTransformSnapshot.GetSnapshotCollection(_targetParents);

            SnapTargetsToSurface();
            CalculateGrabTargetsAnchorVectors();

            if (SessionBegin != null)
            {
                SessionBegin();
            }
            return(true);
        }
示例#3
0
 public void TakeRedoTargetSnapshots()
 {
     if (_wasExecuted)
     {
         return;
     }
     _redoTargetSnapshots = LocalTransformSnapshot.GetSnapshotCollection(_targetParents);
 }
示例#4
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();
         }
     }
 }
示例#5
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);
        }
        private bool Begin(IEnumerable <GameObject> targetObjects)
        {
            if (_state != State.Inactive || _sharedHotkeys == null || targetObjects == null)
            {
                return(false);
            }

            if (!IdentifyTargetParents(targetObjects) ||
                !IdentifyTargetObjects(targetObjects))
            {
                _targetParents.Clear();
                _targetObjects.Clear();
                return(false);
            }

            _state = State.SelectPivot;
            _preTargetTransformSnapshots = LocalTransformSnapshot.GetSnapshotCollection(_targetParents);

            if (SessionBegin != null)
            {
                SessionBegin();
            }
            return(true);
        }
        public void End()
        {
            if (_state == State.Inactive)
            {
                return;
            }

            _targetObjects.Clear();
            _state = State.Inactive;

            var postObjectTransformChangedAction = new PostObjectTransformsChangedAction(_preTargetTransformSnapshots, LocalTransformSnapshot.GetSnapshotCollection(_targetParents));

            postObjectTransformChangedAction.Execute();
            _targetParents.Clear();

            if (SessionEnd != null)
            {
                SessionEnd();
            }
        }
        public void End()
        {
            if (_state == State.Inactive)
            {
                return;
            }

            _grabTargets.Clear();
            _state = State.Inactive;
            _grabSurfaceInfo.SurfaceType = GrabSurfaceType.Invalid;

            PostObjectTransformsChangedAction postObjectTransformChangedAction = new PostObjectTransformsChangedAction(_preTargetTransformSnapshots, LocalTransformSnapshot.GetSnapshotCollection(_targetParents));

            postObjectTransformChangedAction.Execute();
            _targetParents.Clear();

            if (SessionEnd != null)
            {
                SessionEnd();
            }
        }
示例#9
0
        public override void OnGizmoDragEnd(int handleId)
        {
            if (_transformableParents.Count != 0)
            {
                var postObjectTransformChangedAction = new PostObjectTransformsChangedAction(_preTransformSnapshots, LocalTransformSnapshot.GetSnapshotCollection(_targetObjects));
                postObjectTransformChangedAction.Execute();
            }

            RefreshPositionAndRotation();
        }
示例#10
0
 public override void OnGizmoDragBegin(int handleId)
 {
     _preTransformSnapshots      = LocalTransformSnapshot.GetSnapshotCollection(_targetObjects);
     _transformableParents       = GetTransformableParentObjects();
     _targetGroupAABBOnDragBegin = GetTargetObjectGroupWorldAABB();
 }