jeudi 25 juin 2020

Unity: Access Editor specific type from inside running Editor

Basically I want to run a static function from inside game code that targets an editor script inside the Editor folder where the function and type are static. I'm unsure what assembly the editor scripts will be in, if this is the correct way to call them, and if it's even possible to access the assembly that custom editor scripts are inside from running code (inside the editor though, no requirement to run on builds)

essentially trying to do

System.Reflection.Assembly editorAssembly = null;
        System.Reflection.Assembly[] allAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
        foreach (System.Reflection.Assembly assem in allAssemblies)
        {
            if (assem.FullName == "???UnityEditorMaybe?")
            editorAssembly = assem;
        }
        Type MyStaticType = editorAssembly.GetType("MyStaticType");
        MyStaticType .GetMethod("DoThing").Invoke(null,null);




Aucun commentaire:

Enregistrer un commentaire