Unity2d图像优化

时间:2018-09-05 10:15:10

标签: unity3d

我想在我的游戏中制作等轴测图。 这是我项目的原型

enter image description here

此项目仅由这张图片完成

enter image description here

通过定位此图片

但我遇到了问题,该项目在移动设备上运行速度较慢。(20fps)

所以我想问这些问题:

  1. 统一2d不利于投放许多图像?

  2. 如果我在屏幕上渲染许多图像,该如何优化?

“每个立方体都可以更改位置”

cube.cs 每个多维数据集的脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cube : MonoBehaviour {

// Field
private float vX_pos = 0;
private float vY_pos = 0;
private float vZ_pos = 0;
private int image = 0;
private float rX_pos = 0;
private float rY_pos = 0;


// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    //Cal_Pos(vX_pos,vY_pos,vZ_pos);
}
//init for position.
public void Init_Cube(float X ,float Y ,float Z , int Image = 0)
{
    this.vX_pos = X;
    this.vY_pos = Y;
    this.vZ_pos = Z;
    this.image = Image;
    Debug.Log("position : " + "(" + X +","+ Y + "," + Z + "," + ")");
    Cal_Pos(vX_pos, vY_pos, vZ_pos);
}
//for  x,y,z claculate x,y pos
private void Cal_Pos(float x, float y, float z)
{
    rX_pos = (float)((y - x) * (1.6));
    rY_pos = (float)((y + x) * (-0.8) + z * 1.4);
    transform.position = new Vector3(rX_pos, rY_pos,0 - (vX_pos+vY_pos+vZ_pos));
    //Debug.Log("ID:" + "(" + x + "," + y + "," + z + "," + ")"+" X = " + rX_pos + "," + "Y = " + rY_pos);
}
}

operation.cs 此代码用于for,创建多维数据集和定位多维数据集

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Operation : MonoBehaviour {

// Use this for initialization
void Start () {
    GameObject[,,] Cube_Map = new GameObject[ 50, 50, 50 ];
    for (int y = 0; y < 7; y++)
    {
        for (int x = 0; x < 7; x++)
        {
            for (int z = 0; z < 6; z++)
            {
                Cube_Map[x, y, z] = Instantiate(Resources.Load("Prefabs/Cube_Sell", typeof(GameObject))) as GameObject; ;
                Cube_Map[x, y, z].GetComponent<Cube>().Init_Cube(x, y, z);
            }
        }
    }
}

// Update is called once per frame
void Update () {

}
}

0 个答案:

没有答案