Beispiel #1
0
    void LoadSceneAsset()
    {
        filePath = EditorUtility.OpenFilePanel("打开", filePath, "asset");
        if (string.IsNullOrEmpty(filePath) || !filePath.Contains(".asset"))
        {
            return;
        }
        MapWorldAsset mapWorldAsset = (MapWorldAsset)AssetDatabase.LoadAssetAtPath("Assets" + filePath.Replace(Application.dataPath, ""), typeof(MapWorldAsset));

        if (mapWorldAsset != null)
        {
            for (int i = 0; i < mapWorldAsset.mapScenes.Count; i++)
            {
                currMapScene           = new GameObject("Map" + (i + 1)).AddComponent <MapScene>();
                currMapScene.offsetX   = mapWorldAsset.mapScenes[i].offsetX;
                currMapScene.offsetY   = mapWorldAsset.mapScenes[i].offsetY;
                currMapScene.mapSizeX  = mapWorldAsset.mapScenes[i].mapSizeX;
                currMapScene.mapSizeY  = mapWorldAsset.mapScenes[i].mapSizeY;
                currMapScene.worldType = mapWorldAsset.mapScenes[i].worldType;
                currMapScene.layers    = new List <MapEditorSortLayer>(mapWorldAsset.mapScenes[i].layers);
                for (int n = 0; n < mapWorldAsset.mapScenes[i].layerItems.Count; n++)
                {
                    currMapScene.layerItems.Add(new MapLayerItem());
                    currMapScene.layerItems[n].posList = new List <int>(mapWorldAsset.mapScenes[i].layerItems[n].posList);
                    currMapScene.layerItems[n].items   = new List <MapResourceItem>(mapWorldAsset.mapScenes[i].layerItems[n].items);
                }
                mapSceneList.Add(currMapScene);
                currMapScene.FreshMapGrid();
                currMapScene.UpdateMap();
            }
        }
        FreshResource();
    }
Beispiel #2
0
 void AddTile(Vector2 pos, MapResourceItem selectedTile)
 {
     currMapScene.AddGrid(((int)pos.x - currMapScene.offsetX) * 10000 + (int)pos.y - currMapScene.offsetY, selectedTile);
     currMapScene.UpdateMap();
 }