Skip to content

Instantly share code, notes, and snippets.

@demonixis
Last active November 29, 2018 17:27
Show Gist options
  • Save demonixis/a8436f4ebe18764f167ced3bcdb1a13f to your computer and use it in GitHub Desktop.
Save demonixis/a8436f4ebe18764f167ced3bcdb1a13f to your computer and use it in GitHub Desktop.
This WIP shim allows you to build the PostProcess Stack V2 for Unity with the Universal Windows Platform target. But before you have to add a little change in the `PostProcessEffectSettings.cs`. Please read the first comment.
#if !UNITY_EDITOR && UNITY_WSA
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
/*
You've to edit the file PostProcessEffectSettings.cs (~ line 27) and add a preprocessor instruction
like this because the property MetadataToken is not supported on UWP and it can't be added with an extension.
#if !UNITY_WSA
.OrderBy(t => t.MetadataToken) // Guaranteed order
#endif
Place this file where you want in your code and you're able to compile without IL2CPP ;)
*/
namespace UnityEngine.Rendering.PostProcessing
{
public static class TypeExtension
{
public static bool IsDefined(this Type thisType, Type type, bool inherit)
{
return thisType.GetTypeInfo().GetCustomAttribute(type) != null;
}
public static object[] GetCustomAttributes(this Type thisType, Type attributeType, bool inherit)
{
return thisType.GetType().GetCustomAttributes(attributeType, inherit);
}
public static bool IsSubclassOf(this Type thisType, Type c)
{
return thisType == c || thisType.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
}
}
public static class AssemblyExtension
{
public static Type[] GetTypes(this Assembly thisAssembly)
{
return thisAssembly.GetTypes();
}
}
public class AppDomain
{
public static AppDomain CurrentDomain { get; private set; }
static AppDomain()
{
CurrentDomain = new AppDomain();
}
public List<Assembly> GetAssemblies()
{
return GetAssembliesAsync().Result;
}
public async Task<List<Assembly>> GetAssembliesAsync()
{
var assemblies = new List<Assembly>();
var files = await global::Windows.ApplicationModel.Package.Current.InstalledLocation.GetFilesAsync();
if (files == null)
return assemblies;
foreach (var file in files.Where(file => file.FileType == ".dll" || file.FileType == ".exe"))
{
try
{
assemblies.Add(Assembly.Load(new AssemblyName(file.DisplayName)));
}
catch (Exception ex)
{
Debug.Log(ex.Message);
}
}
return assemblies;
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment