Я хочу сделать изометрическую карту в моей игре.
Это прототип моего проекта
![enter image description here](https://i.stack.imgur.com/FBdmU.gif)
этот проект сделан только этим изображением
![enter image description here](https://i.stack.imgur.com/6A9Z5.png)
позиционируя это изображение
но у меня проблема, этот проект будет медленнее в мобильном. (20fps)
поэтому я хочу задать следующие вопросы:
Единство 2d плохо для ранжирования многих изображений ??
если я рендерил много изображений на экране, как я могу оптимизировать?
"каждый куб может изменить положение"
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 () {
}
}