Пример #1
0
        /// <summary>
        /// 开启振动
        /// </summary>
        /// <param name="csPreset">预设值</param>
        /// <returns></returns>
        public CameraShake Play(CameraShakePresets csPreset)
        {
            var         caObj       = recyclePool.GetObject();
            CameraShake cameraShake = caObj.GetComponent <CameraShake>();

            if (cameraShake == null)
            {
                caObj.AddComponent <CameraShake>();
                cameraShake = caObj.GetComponent <CameraShake>();
            }

            if (cameraShake != null)
            {
                var             dataList = mCameraShakeDataList.cameraShakeDataList;
                CameraShakeData data     = null;
                for (int i = 0; i < dataList.Count; i++)
                {
                    if (dataList[i].presetsType == csPreset)
                    {
                        data = dataList[i];
                        break;
                    }
                }
                if (data != null)
                {
                    cameraShake.UpdateData(data);
                    cameraShake.OnInit();
                    activeShakeList.Add(cameraShake);
                }
            }
            return(cameraShake);
        }
Пример #2
0
 public void UpdateData(CameraShakeData data)
 {
     if (data != null)
     {
         mShakeType    = data.mShakeType;
         mNoiseType    = data.mNoiseType;
         MoveExtents   = data.MoveExtents;
         RotateExtents = data.RotateExtents;
         Speed         = data.Speed;
         Duration      = data.Duration;
     }
 }
Пример #3
0
        /// <summary>
        /// 开启振动
        /// </summary>
        /// <param name="csPreset">预设值</param>
        /// <returns></returns>
        public CameraShake Play(CameraShakeData data)
        {
            var         caObj       = recyclePool.GetObject();
            CameraShake cameraShake = caObj.GetComponent <CameraShake>();

            if (cameraShake == null)
            {
                caObj.AddComponent <CameraShake>();
                cameraShake = caObj.GetComponent <CameraShake>();
            }

            if (cameraShake != null)
            {
                if (data != null)
                {
                    cameraShake.UpdateData(data);
                    activeShakeList.Add(cameraShake);
                }
            }
            return(cameraShake);
        }