Пример #1
0
        public static void SetWorldScale(Transform destTransform, Vector3 sourceLocalScale, Vector3 sourceParentScale)
        {
            var destParentScale = FollowThis.GetParentScale(destTransform);

            destTransform.localScale = new Vector3(sourceLocalScale.x * (sourceParentScale.x / destParentScale.x),
                                                   sourceLocalScale.y * (sourceParentScale.y / destParentScale.y),
                                                   sourceLocalScale.z * (sourceParentScale.z / destParentScale.z));
        }
Пример #2
0
 public void UpdateLayout()
 {
     FollowThis.Follow(this.CachedTransform,
                       this.followers,
                       this.updateScale,
                       this.updateRotation,
                       this.updatePosition,
                       CoordinateType.World == this.coordinate);
 }
Пример #3
0
 public void UpdateLayout()
 {
     this.followBuffer[0] = this.CachedTransform;
     FollowThis.Follow(this.target,
                       this.followBuffer,
                       this.updateScale,
                       this.updateRotation,
                       this.updatePosition,
                       CoordinateType.World == this.coordinate);
 }
Пример #4
0
        public static void Follow(Transform target,
                                  IEnumerable <Transform> followers,
                                  bool S,
                                  bool R,
                                  bool T,
                                  bool W)
        {
            if (!target)
            {
                return;
            }

            var parentScale = S && W?FollowThis.GetParentScale(target) : Vector3.zero;

            var worldRotation = R && W ? target.rotation : Quaternion.identity;
            var worldPosition = T && W ? target.position : Vector3.zero;

            var localScale    = S ? target.localScale : Vector3.zero;
            var localRotation = R ? target.localRotation : Quaternion.identity;
            var localPosition = T ? target.localPosition : Vector3.zero;

            var enumerator = followers.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var follower = enumerator.Current;
                if (!follower)
                {
                    continue;
                }

                if (W)
                {
                    if (S)
                    {
                        FollowThis.SetWorldScale(follower, localScale, parentScale);
                    }

                    if (R)
                    {
                        follower.rotation = worldRotation;
                    }

                    if (T)
                    {
                        follower.position = worldPosition;
                    }
                }
                else
                {
                    if (S)
                    {
                        follower.localScale = localScale;
                    }

                    if (R)
                    {
                        follower.localRotation = localRotation;
                    }

                    if (T)
                    {
                        follower.localPosition = localPosition;
                    }
                }
            }
        }