void CreateMap()
        {
            string rootPath      = IOHelpers.RequireFolder(ROOT_FOLDER);
            string mapFolderPath = IOHelpers.RequireFolder(rootPath, MAP_FOLDER);
            string mapPath       = IOHelpers.GetAvailableAssetPath(mapFolderPath, MAP_NAME);
            string configName;

            switch (caveGenType)
            {
            case CaveGeneratorUI.CaveGeneratorType.ThreeTiered:
                configName = THREE_TIER_CONFIG_NAME;
                break;

            case CaveGeneratorUI.CaveGeneratorType.RockOutline:
                configName = ROCK_CAVE_CONFIG_NAME;
                break;

            default:
                throw CaveGenTypeException;
            }
            string             property       = string.Format("{0}.{1}", configName, MAP_GEN_NAME);
            SerializedProperty mapGenProperty = serializedObject.FindProperty(property);
            var mapGen  = (MapGenModule)mapGenProperty.objectReferenceValue;
            var map     = mapGen.Generate();
            var texture = map.ToTexture();

            IOHelpers.SaveTextureAsPNG(texture, mapPath);
        }
Example #2
0
        void SaveMap()
        {
            var       compoundModule = BuildModule();
            string    folderPath     = NodeEditorSettings.PathToMapFolder;
            Texture2D texture        = compoundModule.Generate().ToTexture();
            string    texturePath    = IOHelpers.GetAvailableAssetPath(folderPath, SAVED_TEXTURE_NAME);

            IOHelpers.SaveTextureAsPNG(texture, texturePath);
        }
        static void SaveAsPNG(MenuCommand command)
        {
            var       module      = (MapGenModule)command.context;
            string    folderPath  = IOHelpers.GetFolderContainingAsset(module);
            Texture2D texture     = module.Generate().ToTexture();
            string    name        = string.Format("{0}{1}.png", module.name, MapImporter.MAP_SUBSTRING);
            string    texturePath = IOHelpers.GetAvailableAssetPath(folderPath, name);

            IOHelpers.SaveTextureAsPNG(texture, texturePath);
        }
        void CreateMap()
        {
            string rootPath      = IOHelpers.RequireFolder(ROOT_FOLDER);
            string mapFolderPath = IOHelpers.RequireFolder(rootPath, MAP_FOLDER);
            string mapPath       = IOHelpers.GetAvailableAssetPath(mapFolderPath, MAP_NAME);
            var    mapGen        = GetMapGenModule();
            var    map           = mapGen.Generate();
            var    texture       = map.ToTexture();

            IOHelpers.SaveTextureAsPNG(texture, mapPath);
        }