summaryrefslogtreecommitdiff
path: root/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility
diff options
context:
space:
mode:
Diffstat (limited to 'VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility')
-rw-r--r--VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs70
-rw-r--r--VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs.meta11
2 files changed, 81 insertions, 0 deletions
diff --git a/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs
new file mode 100644
index 00000000..ee656b38
--- /dev/null
+++ b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs
@@ -0,0 +1,70 @@
+using System.Reflection;
+using System.Collections.Generic;
+using UnityEngine;
+using System;
+using System.Linq;
+using UnityEditor;
+
+public class VRCSdk3Analysis
+{
+ static Assembly GetAssemblyByName(string name)
+ {
+ return AppDomain.CurrentDomain.GetAssemblies().
+ SingleOrDefault(assembly => assembly.GetName().Name == name);
+ }
+
+ static List<Component> GetSceneComponentsFromAssembly( Assembly assembly )
+ {
+ if (assembly == null)
+ return new List<Component>();
+
+ Type[] types = assembly.GetTypes();
+
+ List<Component> present = new List<Component>();
+ foreach (var type in types )
+ {
+ if (!type.IsSubclassOf(typeof(MonoBehaviour)))
+ continue;
+
+ var monos = VRC.Tools.FindSceneObjectsOfTypeAll(type);
+ present.AddRange(monos);
+ }
+ return present;
+ }
+
+ public enum SdkVersion
+ {
+ VRCSDK2,
+ VRCSDK3
+ };
+
+ public static List<Component> GetSDKInScene(SdkVersion version)
+ {
+ var assembly = GetAssemblyByName( version.ToString() );
+ return GetSceneComponentsFromAssembly(assembly);
+ }
+
+ public static bool IsSdkDllActive(SdkVersion version)
+ {
+ string assembly = version.ToString();
+ PluginImporter importer = GetImporterForAssemblyString(assembly);
+ if (importer == false)
+ {
+ //Handle Avatar Dll Split
+ importer = GetImporterForAssemblyString(assembly + "A");
+ if (importer == false)
+ return false;
+ }
+
+ return importer.GetCompatibleWithAnyPlatform();
+ }
+
+ public static PluginImporter GetImporterForAssemblyString(string assembly)
+ {
+#if VRCUPM
+ return AssetImporter.GetAtPath($"Packages/com.vrchat.{assembly.ToLower()}/Runtime/VRCSDK/Plugins/{assembly}.dll") as PluginImporter;
+#else
+ return AssetImporter.GetAtPath($"Assets/VRCSDK/Plugins/{assembly}.dll") as PluginImporter;
+#endif
+ }
+}
diff --git a/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs.meta b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs.meta
new file mode 100644
index 00000000..8a2d89cb
--- /dev/null
+++ b/VRCSDK3AvatarsLegacy/Assets/VRCSDK/Dependencies/VRChat/Editor/SDK3Compatibility/VRCSdk3Analysis.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 93710d221addc0243ba90dd20369844b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: