Firstborn/Assets/Scripts/LoadMod.cs
Schaken-Mods 774d18a99d 5/18/2023 Update
made most of the game Moddable. There is an in editor tool to make the mods and set them all up, and im making an external tool that will show your mods, lets you edit any information and it will pack it up and upload it. currently working on the uploading. Next I will make the game able to download and install. - Fuck Nexus.
2023-05-18 20:28:45 -05:00

44 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.AddressableAssets;
using UnityEngine.UI;
public class LoadMod : MonoBehaviour
{
public string modDir;
// Start is called before the first frame update
public void openMod()
{
modDir = UnityEngine.Application.dataPath+"/Mods";
string dir = modDir;
AsyncOperationHandle<IResourceLocator> loadContentCatalogAsync = Addressables.LoadContentCatalogAsync(@"" + dir);
loadContentCatalogAsync.Completed += OnCompleted;
}
private void OnCompleted(AsyncOperationHandle<IResourceLocator> obj)
{
IResourceLocator resourceLocator = obj.Result;
resourceLocator.Locate("Scene", typeof(GameObject), out IList<IResourceLocation> locations);
if (locations != null)
{
foreach (IResourceLocation resourceLocation in locations)
{
GameObject resourceLocationData = (GameObject)resourceLocation.Data;
Addressables.InstantiateAsync(resourceLocation);
}
}
}
}