How load embedded .uxml or .uss resource into dll ,

There is a dll containing embedded resources as a .uxml and .uss file. The same dll defines the EditorWindow class that should use them to create an interface,

Well I haven’t used it yet but I think what you’re looking for is Assembly.GetManifestResourceStream. Of course first you have to get a reference to the Assembly you’re interested in. I guess something like that should work:

public class DLLResource
{
    public static byte[] LoadResource<T>(string aResourceName)
    {
        var assembly = typeof(T).Assembly;
        using (var stream = assembly.GetManifestResourceStream(aResourceName))
        {
            byte[] data = new byte[stream.Length];
            stream.Read(data, 0, data.Length);
            return data;
        }
    }
    public static string LoadStringResource<T>(string aResourceName)
    {
        var data = LoadResource<T>(aResourceName);
        return System.Text.Encoding.UTF8.GetString(data);
    }
}

With this helper class you can simply use

string text = DLLResource.LoadStringResource<CustomEditor>("YourDLLResourceName");

The generic type you pass in could be any type defined in the assembly you want to get that resource from.

However as far as I can tell there is no actual way to manually parse an USS or UXML file dynamically. So in order to get the actual asset it has to be physically present inside the project. Of course you can use the above method to simple extract the file(s) into the EditorResources folder, refresh the asset database and then load the StyleSheet / tree as usual from the resources.

Haven’t really used UIElements yet. If there’s really no way to load an UXML or USS file dynamically that’s quite a let-down. Though maybe there’s a way I haven’t found yet ^^.

@Bunny83 Thank you for the answer, I came to the same decision you made. I was interested in just a part of uxml and uml, but I did not find any open parsers(