Esempio n. 1
0
        public void Play()
        {
            Init();


            if (!mInited)
            {
                return;
            }

            //场景切换,会删除Go,所以要检查
            if (mMeshObj == null)
            {
                InitMeshObj();
                return;
            }

            //gameObject.SetActive(true);
            if (mMeshObj != null)
            {
                mMeshObj.SetActive(true);
            }

            //如果开始的点太远,重置一遍,因为光效优化的位置是在99999
            //if (mSnapshotList[0].PointStart.sqrMagnitude > 100000000 ||
            //    mSnapshotList[0].PointEnd.sqrMagnitude > 100000000 ||
            //    RelaryLifeFrame != LifeFrame)
            //{
            //RelaryLifeFrame = LifeFrame;
            InitOriginalElements();
            InitSpline();
            // }

            mFadeT          = 1f;
            mIsFading       = false;
            mFadeTime       = 1f;
            mFadeElapsedime = 0f;
            mElapsedTime    = 0f;

            //重置
            for (int i = 0; i < mSnapshotList.Count; i++)
            {
                mSnapshotList[i].PointStart = PointStart.position;
                mSnapshotList[i].PointEnd   = PointEnd.position;

                //mSpline.ControlPoints[i].Position = mSnapshotList[i].Pos;
                //mSpline.ControlPoints[i].Normal = mSnapshotList[i].PointEnd - mSnapshotList[i].PointStart;
            }

            //重置
            RefreshSpline();
            UpdateVertex();
            GenerateMaterialInstance();
            UpdateMaterial();
            PlayMaterialControl();
            EffectUtily.DispatchRender(m_Render, m_Render.sharedMaterial);

            mVertexPool.LateUpdate();
            bActive = true;
        }
Esempio n. 2
0
        private void LateUpdate()
        {
            if (!_inited)
            {
                return;
            }

            if (CapFps)
            {
                _time += Time.deltaTime;
                if (_time < 1f / 90)
                {
                    return;
                }

                _time = 0;
            }

            _frameNum++;

            if (_frameNum == _skipFirstFrames + 1)
            {
                _vertexPool.SetMeshObjectActive(true);

                _spline.Granularity = Granularity;
                _spline.Clear();
                for (int i = 0; i < TrailLength; i++)
                {
                    _spline.AddControlPoint(CurHeadPos, PointStart.position - PointEnd.position);
                }
                _snapshotList.Clear();
                _snapshotList.Add(new Element(PointStart.position, PointEnd.position));
                _snapshotList.Add(new Element(PointStart.position, PointEnd.position));
            }
            else if (_frameNum < _skipFirstFrames + 1)
            {
                return;
            }

            UpdateHeadElem();
            RecordCurElem();
            RefreshSpline();
            UpdateVertex();
            _vertexPool.LateUpdate();
        }