美文网首页我爱编程
Multiplatform Runtime Level Edit

Multiplatform Runtime Level Edit

作者: Bonging | 来源:发表于2018-04-08 21:51 被阅读0次

Multiplatform Runtime Level Editor Extension - Save/Load file picker(另外一个扩展插件)

概要

文件选择器扩展允许您保存和加载多个关卡文件。它包含一个弹出窗口,允许您输入新的文件名或从现有文件中选择一个关卡。(Unity资源商店中这个扩展插件的购买链接)

将关卡上传到Steam Workshop

使用下面的单行代码来激活Steam Workshop关卡的数据库格式。该代码行应该在游戏启动时执行,例如在主脚本的Awake方法中。关卡将保存在包含关卡文件和图标的文件夹中。这是Steam要求的,只有文件夹可以上传到Steam Workshop,无法上传单个文件。

LE_LevelEditor.Extensions.LE_ExtensionInterface.FileSelectionInstance.LevelDB = new LE_LevelEditor.Extensions.LE_LevelDatabase_SteamWorkshop();

完成此操作后,您可以使用Steam Workshop - Easy Steamworks Integration(也是Unity商店的一个插件)来上传和下载关卡。如果要使用文件选择器菜单加载Workshop关卡,请将Steam Workshop项目的根文件夹传递给LE_LevelDatabase_SteamWorkshop类的构造函数。当你想要在你的脚本中的时候可以替换LevelDB属性。

下面的示例脚本将允许玩家选择一个关卡并上传它:

using System.IO;

using UnityEngine;

using LE_LevelEditor.Extensions;

using LE_LevelEditor.UI;

using LevelFile = LE_LevelEditor.Extensions.LE_ExtensionInterface.FileSelectionExtensionLoader.LevelFile;

using LapinerTools.Steam;

using LapinerTools.Steam.UI;

using LapinerTools.Steam.Data;

using LapinerTools.uMyGUI;

// Add this example script to your level editor scene.

// It will change the level folder structure of the saved levels to match Steam Workshop requirements.

// Press F1 while running the scene to upload a level.

public class MRLE_SteamWorkshop_ESI_Example : MonoBehaviour

{

  private void Awake()

  {

      LE_LevelEditor.Extensions.LE_ExtensionInterface.FileSelectionInstance.LevelDB = new LE_LevelEditor.Extensions.LE_LevelDatabase_SteamWorkshop();

  }

  void Update()

  {

      if (Input.GetKeyUp(KeyCode.F1))

      {

        LE_FileSelectionHelpers.SelectLevel(this, "Upload Level", "Which level do you want to upload to Steam Workshop?", (int p_selectedLevelIndex, LevelFile[] p_levelFiles)=>

            {

              // get Steam item from folder

              string levelFolder = Path.GetDirectoryName(p_levelFiles[p_selectedLevelIndex].PathData);

              WorkshopItemUpdate itemUpdate = SteamWorkshopMain.Instance.GetItemUpdateFromFolder(levelFolder);

              if (itemUpdate == null)

              {

                  // level was never uploaded => prefil the upload dialog

                  itemUpdate = new WorkshopItemUpdate();

                  itemUpdate.Name = p_levelFiles[p_selectedLevelIndex].Name;

                  itemUpdate.IconPath = p_levelFiles[p_selectedLevelIndex].PathIcon;

                  itemUpdate.ContentPath = levelFolder;

              }

              // show the Steam Workshop item upload popup

              ((SteamWorkshopPopupUpload)uMyGUI_PopupManager.Instance.ShowPopup("steam_ugc_upload")).UploadUI.SetItemData(itemUpdate);

            });

      }

  }

}

原文链接:http://www.freebord-game.com/index.php/multiplatform-runtime-level-editor/documentation/save-load-file-picker

相关文章

网友评论

    本文标题:Multiplatform Runtime Level Edit

    本文链接:https://www.haomeiwen.com/subject/hjtvhftx.html