Esempio n. 1
0
    /// <summary>
    /// 绘制一个幻影
    /// </summary>
    /// <param name="propertyBlock"></param>
    /// <param name="afterimageData"></param>
    private void DrawAfterimageItem(MaterialPropertyBlock propertyBlock, AfterimageData afterimageData)
    {
        for (int i = 0; i < afterimageData.AM4x4List.Count; i++)
        {
            AfterimageMatrix4x4 item = afterimageData.AM4x4List[i];

            //设置贴图
            propertyBlock.SetTexture(idMainTex, item.sprite.texture);
            //获得网格
            var mesh = SpriteToMesh(item.sprite);


            buffer.DrawMesh(mesh, Matrix4x4.TRS(item.position, item.rotation, item.localScale), item.material, 0, 0, propertyBlock);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 幻影数据刷新
    /// </summary>
    private void DataUptate()
    {
        if ((transform.position - lastPosition).magnitude < spacing)
        {
            return;
        }



        lastPosition = transform.position;


        AfterimageData afterimageData = new AfterimageData();

        //设置时间
        afterimageData.live = live;

        afterimageData.color = color;

        //遍历所有精灵创建一个幻影
        for (int i = 0; i < spriteList.Count; i++)
        {
            var item = spriteList[i];
            //获得当前精灵的信息
            AfterimageMatrix4x4 afterimageMatrix4X4 = new AfterimageMatrix4x4(
                item.transform.position,
                item.transform.rotation,
                item.transform.lossyScale,
                item.sprite,
                item.material);
            //添加当前精灵到幻影中
            afterimageData.AM4x4List.Add(afterimageMatrix4X4);
        }
        //将新的幻影添加到数据中
        AfterimageDataList.Add(afterimageData);
    }