Commit 96b774b7 authored by Luke A Smith's avatar Luke A Smith
Browse files

Merge branch 'Editor_Optimization' into 'master'

Optimized editor. Correctly checks for same existing prefab at position and dosn…

See merge request !2
parents abe40ee9 3d850791
......@@ -92,18 +92,24 @@ public class MapEditor : MonoBehaviour
if(Tile != null)
{
GameObject go = (GameObject)GameObject.Instantiate(Tile, new Vector3(pos.x, pos.y, Layer), Quaternion.identity);
go = PrefabUtility.ConnectGameObjectToPrefab(go, Tile);
go.transform.position = new Vector3(pos.x, pos.y, Layer);
SpriteRenderer sr = go.GetComponent<SpriteRenderer>();
if(sr != null)
if(!World.posIsThis(pos, Tile))
{
sr.sortingOrder = layer * -World.SORTING_ORDER_MULT;
Debug.Log("new");
GameObject go = (GameObject)GameObject.Instantiate(Tile, new Vector3(pos.x, pos.y, Layer), Quaternion.identity);
go = PrefabUtility.ConnectGameObjectToPrefab(go, Tile);
go.transform.position = new Vector3(pos.x, pos.y, Layer);
SpriteRenderer sr = go.GetComponent<SpriteRenderer>();
if(sr != null)
{
sr.sortingOrder = layer * -World.SORTING_ORDER_MULT;
}
go.transform.parent = Tiles;
World.set(pos, layer, go);
}
go.transform.parent = Tiles;
World.set(pos, layer, go);
else
Debug.Log("new");
}
else
{
......
......@@ -61,7 +61,8 @@ public static class World
{
if(!posInBounds(x, y, z))
return false;
destroyPos(x,y,z);
destroyPos(x, y, z);
map[x][y][z] = go;
return true;
......@@ -99,7 +100,8 @@ public static class World
{
if(!posInBounds(x, y, z))
return false;
return PrefabUtility.GetPrefabObject(map[x][y][z]) == PrefabUtility.GetPrefabObject(go);
return PrefabUtility.GetPrefabParent(map[x][y][z]) == go;
}
......
m_EditorVersion: 5.5.0xf3Linux
m_EditorVersion: 5.3.5f1
m_StandardAssetsVersion: 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment