I need to load a Script from an external dll, but it’s a table of dll and I need to load all of this files (the names cannot be entered, I just need an dll name loader)
Sorry for my bad english, I speak french.
Thnks for interrsing to my problem
I need to load a Script from an external dll, but it’s a table of dll and I need to load all of this files (the names cannot be entered, I just need an dll name loader)
Sorry for my bad english, I speak french.
Thnks for interrsing to my problem
Could you give a better example of what you’re trying to do? You can use Assembly.Load to load external assemblies and there are ways to catch and load dependencies as well…
Sorry for waiting.
using System;
using System.IO;
using UnityEngine;
public class ScriptLoader
{
public void LoadScripts()
{
string[] Assemblys = Directory.GetFiles(Application.dataPath + "/Models", "*.fbx");
int AssemblyNumber = Directory.GetFiles(Application.dataPath + "/Add-Ons", "*.dll").Length;
int WhileNumber = 0;
while (WhileNumber <= AssemblyNumber)
{
//Assembly.load(Assemblys[WhileNumber])
WhileNumber++
}
}
}
Um that’s broken in many ways. You’re attempting to load the fbx files from one folder and count assemblies from another. And what are you going to do once they DLLs are loaded?
If the line of fbx loading is not here, that’s works ?
And if that’s works,how do I load Load() in this assemblys ?
[I load Load() in this assemblys]
using System;
using System.IO;
using UnityEngine;
using System.Reflection;
public class ScriptLoader
{
public void LoadScripts()
{
string[] Assemblys[] = Directory.GetFiles(Application.dataPath + "/Add-Ons", "*.dll");
int AssemblyNumber = Directory.GetFiles(Application.dataPath + "/Add-Ons", "*.dll").Length;
int WhileNumber = 0;
while (WhileNumber <= AssemblyNumber)
{
Assembly.Load(Assemblys[WhileNumber])
Assemblys[WhileNumber].Load();
WhileNumber++
}
}
}
Yeah. But then you need to know what you’re loading. I use this approach from time to time by leveraging a core assembly with interfaces. My external assembly references the same core and classes implement core interfaces. Then from the loaded assembly I search for types that implement those interfaces and use them.
Now, I have an other problem, all of my scripts are stocked on a string, how do I use the name stored in the string because only the string options can be used
Once your assemblies are loaded use Type.GetType(“Namespace.TypeName”)