示例#1
0
        /////////////////////////////////////////////////////跟随///////////////////////////////
        void UpdateFollow(float deltaTime)
        {
            foreach (KeyValuePair <Transform, FollowInfo> kv in followInfoDict)
            {
                FollowInfo followInfo = kv.Value;
                if (followInfo.transform == null || followInfo.followTransform == null)
                {
                    deleteCache.Add(followInfo.transform);
                }
                else
                {
                    followInfo.transform.position = followInfo.followTransform.position;
                }
            }

            if (deleteCache.Count > 0)
            {
                for (var i = 0; i < deleteCache.Count; i++)
                {
                    Transform transform = deleteCache[i];
                    followInfoDict.Remove(transform);
                }

                deleteCache.Clear();
            }
        }
示例#2
0
        public void Follow(Transform transform, Transform followTransform)
        {
            FollowInfo followInfo  = null;
            bool       isContained = followInfoDict.TryGetValue(transform, out followInfo);

            if (!isContained)
            {
                followInfo                = new FollowInfo();
                followInfo.transform      = transform;
                followInfoDict[transform] = followInfo;
            }

            followInfo.followTransform = followTransform;
        }