コード例 #1
0
    public void LoadBluePrint()
    {
        if (bluePrintObject != null)
        {
            bluePrint = bluePrintObject.GetComponent <BluePrint>();

            gridWith      = bluePrint.gridWidth;
            gridHeight    = bluePrint.gridHeight;
            bluePrintName = bluePrintObject.name;

            CreateNewGrid();
            GameObject tileContainer = GameObject.Find("TileContainer");

            foreach (Transform tile in tileContainer.transform)
            {
                BluePrintCreatorTile bluePrintCreatorTile = tile.GetComponent <BluePrintCreatorTile>();

                BluePrint.TileDefinition tileDefinition = bluePrint.bluePrintGrid[bluePrintCreatorTile.xPos, bluePrintCreatorTile.yPos];

                bluePrintCreatorTile.tileMaterial = tileDefinition.tileMaterial;
                bluePrintCreatorTile.tileOption   = tileDefinition.tileOption;
            }
            UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
            SaveBluePrint();
        }
    }
コード例 #2
0
    public void SaveBluePrint()
    {
        GameObject tileContainer = GameObject.Find("TileContainer");

        if (tileContainer != null && bluePrintObject != null)
        {
            bluePrint = bluePrintObject.GetComponent <BluePrint>();
            bluePrint.bluePrintGrid = new BluePrint.TileDefinition[gridWith, gridHeight];
            bluePrint.gridWidth     = gridWith;
            bluePrint.gridHeight    = gridHeight;
            foreach (Transform tile in tileContainer.transform)
            {
                BluePrintCreatorTile bluePrintCreatorTile = tile.GetComponent <BluePrintCreatorTile>();

                BluePrint.TileDefinition tileDefinition = new BluePrint.TileDefinition();
                tileDefinition.xPos         = bluePrintCreatorTile.xPos;
                tileDefinition.yPos         = bluePrintCreatorTile.yPos;
                tileDefinition.tileMaterial = bluePrintCreatorTile.tileMaterial;
                tileDefinition.tileOption   = bluePrintCreatorTile.tileOption;

                bluePrint.bluePrintGrid[tileDefinition.xPos, tileDefinition.yPos] = tileDefinition;
            }
        }
    }