I cannot instantiate an object from an Assets(Asset Bundle) package

Asked

Viewed 24 times

1

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);
        }
    }
   }
 }
}

error on line 13: Assets Scripts Modscript.Cs (13,6): CS1597 error: Semicolon after method or access block is not valid

error on line 33

WHAT I HAVE TRIED TO DO:

1-I try to change Gameobject to Object, but the object does not instance, I use packages of Assets and mod.io in this class, supposedly, I compile the Assets package and compress(zip)I upload it to mod.io and download it through the mod browser mod.io which is integrated into the game.

2-loaded.LoadAllAssets<GameObject>();

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.