对象不从资产包实例化

时间:2021-03-25 21:22:22

标签: c# unity3d assetbundle

using System.Collections;
using System.Collections.Generic;
using System.IO;
using ModIO;
using UnityEngine;

public class ModScript : MonoBehaviour{
    public string bundleName = "modbundle";

private void Start()
{
    LoadMods();
}

public void LoadMods()
{
    List<string> mods = ModManager.GetInstalledModDirectories(true);

    for (int i = 0; i < mods.Count; i++)
    {
        string mod = mods[i];
        Debug.Log("Loaded mod " + Path.GetFileName(mod));
        
        string modpath = Path.Combine(mod, bundleName);
        
        var loaded = AssetBundle.LoadFromFile(modpath);
        if (loaded == null)
        {
            Debug.LogError("Failed to load mod " + mod);
            return;
        }
        
        GameObject[] loadedAssets = loaded.LoadAllAssets();

        foreach (GameObject player in loadedAssets)
        {
            if (player.name == "player")
            {
                Instantiate(player);
            }
        }
      }
    }
  }

第 13 行错误:Assets\Scripts\ModScript.cs(13,6):错误 CS1597:方法或访问器块后的分号无效

第 33 行错误

我尝试将 GameObject 更改为 Object 但对象不实例化 我在这个类上使用资产包和 mod.io 这应该是我构建资产包和 zip 我上传到 mod.io 我通过游戏中的 mod.io mod 浏览器下载

0 个答案:

没有答案