public static void EnablePluginPlatform(PluginPlatform platform)
        {
            string path         = GetPlatformPluginPath(platform);
            string disabledPath = path + PluginDisabledSuffix;

            bool pathAlreadyExists        = Directory.Exists(path) || File.Exists(path);
            bool disabledPathDoesNotExist = !Directory.Exists(disabledPath) && !File.Exists(disabledPath);

            if (pathAlreadyExists || disabledPathDoesNotExist)
            {
                return;
            }

            string basePath        = GetCurrentProjectPath();
            string relPath         = path.Substring(basePath.Length + 1);
            string relDisabledPath = relPath + PluginDisabledSuffix;

            AssetDatabase.MoveAsset(relDisabledPath, relPath);
            AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();

            // Force reserialization of platform settings meta data
            EnforcePluginPlatformSettings(platform);
        }
Ejemplo n.º 2
0
    private static string GetPluginBuildTargetSubPath(PluginPlatform target)
    {
        string path = string.Empty;

        switch (target)
        {
        case PluginPlatform.Android:
            path = @"/Android/OVRPlugin.aar";
            break;

        case PluginPlatform.AndroidUniversal:
            path = @"/AndroidUniversal/OVRPlugin.aar";
            break;

        case PluginPlatform.OSXUniversal:
            path = @"/OSXUniversal/OVRPlugin.bundle";
            break;

        case PluginPlatform.Win:
            path = @"/Win/OVRPlugin.dll";
            break;

        case PluginPlatform.Win64:
            path = @"/Win64/OVRPlugin.dll";
            break;

        default:
            throw new ArgumentException("Attempted GetPluginBuildTargetSubPath() for unsupported BuildTarget: " + target);
        }

        return(path);
    }
        public static void EnforcePluginPlatformSettings(PluginPlatform platform)
        {
            string path = GetPlatformPluginPath(platform);

            if (!Directory.Exists(path) && !File.Exists(path))
            {
                path += PluginDisabledSuffix;
            }

            if ((Directory.Exists(path)) || (File.Exists(path)))
            {
                string basePath = GetCurrentProjectPath();
                string relPath  = path.Substring(basePath.Length + 1);

                PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter;
                if (pi == null)
                {
                    return;
                }

                // Disable support for all platforms, then conditionally enable desired support below
                pi.SetCompatibleWithEditor(false);
                pi.SetCompatibleWithAnyPlatform(false);
                pi.SetCompatibleWithPlatform(BuildTarget.Android, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false);
#if UNITY_2017_3_OR_NEWER
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false);
#else
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false);
#endif

                switch (platform)
                {
                case PluginPlatform.Android32:
                    pi.SetCompatibleWithPlatform(BuildTarget.Android, true);
                    pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7");
                    break;

                case PluginPlatform.Android64:
                    pi.SetCompatibleWithPlatform(BuildTarget.Android, true);
                    pi.SetPlatformData(BuildTarget.Android, "CPU", "ARM64");
                    break;

                default:
                    throw new ArgumentException("Attempted to enable platform support for unsupported platform: " + platform);
                }

                AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }
        }
        private static string GetPlatformPluginPath(PluginPlatform platform)
        {
            string path = GetPlatformRootPath();

            switch (platform)
            {
            case PluginPlatform.Android32:
                path += PluginSubPathAndroid32;
                break;

            case PluginPlatform.Android64:
                path += PluginSubPathAndroid64;
                break;

            default:
                throw new ArgumentException("Attempted to enable platform support for unsupported platform: " + platform);
            }

            return(path);
        }
Ejemplo n.º 5
0
    private static string GetPluginBuildTargetSubPath(PluginPlatform target)
    {
        string path = string.Empty;

#if UNITY_WEBGL
        // path = @"error no file for webGL since not doing VR";
#else
        switch (target)
        {
        case PluginPlatform.Android:
            path = @"/Android/OVRPlugin.aar";
            break;

        case PluginPlatform.AndroidUniversal:
            path = @"/AndroidUniversal/OVRPlugin.aar";
            break;

        case PluginPlatform.OSXUniversal:
            path = @"/OSXUniversal/OVRPlugin.bundle";
            break;

        case PluginPlatform.Win:
            path = @"/Win/OVRPlugin.dll";
            break;

        case PluginPlatform.Win64:
            path = @"/Win64/OVRPlugin.dll";
            break;

        default:
            throw new ArgumentException("Attempted GetPluginBuildTargetSubPath() for unsupported BuildTarget: " + target);
        }
#endif

        return(path);
    }
Ejemplo n.º 6
0
 public static void AddPluginPlatform(PluginPlatform plugin_platform)
 {
     s_PluginPlatforms.Add(plugin_platform);
 }
Ejemplo n.º 7
0
    private static void EnablePluginPackage(PluginPackage pluginPkg)
    {
        foreach (var kvp in pluginPkg.Plugins)
        {
            PluginPlatform platform = kvp.Key;
            string         path     = kvp.Value;

            if ((Directory.Exists(path + GetDisabledPluginSuffix())) || (File.Exists(path + GetDisabledPluginSuffix())))
            {
                string basePath        = GetCurrentProjectPath();
                string relPath         = path.Substring(basePath.Length + 1);
                string relDisabledPath = relPath + GetDisabledPluginSuffix();

                AssetDatabase.MoveAsset(relDisabledPath, relPath);
                AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate);

                PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter;
                if (pi == null)
                {
                    continue;
                }

                // Disable support for all platforms, then conditionally enable desired support below
                pi.SetCompatibleWithEditor(false);
                pi.SetCompatibleWithAnyPlatform(false);
                pi.SetCompatibleWithPlatform(BuildTarget.Android, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false);
#if UNITY_2017_3_OR_NEWER
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false);
#else
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false);
#endif

                switch (platform)
                {
                case PluginPlatform.Android:
                    pi.SetCompatibleWithPlatform(BuildTarget.Android, !unityVersionSupportsAndroidUniversal);
                    pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7");
                    break;

                case PluginPlatform.AndroidUniversal:
                    pi.SetCompatibleWithPlatform(BuildTarget.Android, unityVersionSupportsAndroidUniversal);
                    pi.SetPlatformData(BuildTarget.Android, "CPU", "ARM64");
                    break;

                case PluginPlatform.OSXUniversal:
#if UNITY_2017_3_OR_NEWER
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, true);
#else
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, true);
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, true);
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, true);
#endif
                    pi.SetCompatibleWithEditor(true);
                    pi.SetEditorData("CPU", "AnyCPU");
                    pi.SetEditorData("OS", "OSX");
                    pi.SetPlatformData("Editor", "CPU", "AnyCPU");
                    pi.SetPlatformData("Editor", "OS", "OSX");
                    break;

                case PluginPlatform.Win:
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true);
                    pi.SetCompatibleWithEditor(true);
                    pi.SetEditorData("CPU", "X86");
                    pi.SetEditorData("OS", "Windows");
                    pi.SetPlatformData("Editor", "CPU", "X86");
                    pi.SetPlatformData("Editor", "OS", "Windows");
                    break;

                case PluginPlatform.Win64:
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true);
                    pi.SetCompatibleWithEditor(true);
                    pi.SetEditorData("CPU", "X86_64");
                    pi.SetEditorData("OS", "Windows");
                    pi.SetPlatformData("Editor", "CPU", "X86_64");
                    pi.SetPlatformData("Editor", "OS", "Windows");
                    break;

                default:
                    throw new ArgumentException("Attempted EnablePluginPackage() for unsupported BuildTarget: " + platform);
                }

                AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate);
            }
        }

        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
    }
Ejemplo n.º 8
0
    private static void EnablePluginPackage(PluginPackage pluginPkg)
    {
#if UNITY_2020_1_OR_NEWER
        bool activateOpenXRPlugin = pluginPkg.Version >= minimalProductionVersionForOpenXR;
        if (activateOpenXRPlugin && !unityRunningInBatchmode)
        {
            while (true)
            {
                // display a dialog to prompt developer to confirm if they want to proceed with OpenXR backend
                int result = EditorUtility.DisplayDialogComplex("OpenXR Backend",
                                                                "OpenXR is now fully supported by Oculus. However, some of the functionalities are not supported in the baseline OpenXR spec, which would be provided in our future releases.\n\nIf you depend on the following features in your project, please click Cancel to continue using the legacy backend:\n\n  1. Advanced hand tracking features (collision capsule, input metadata, Thumb0, default handmesh)\n  2. Mixed Reality Capture on Rift\n\nNew features, such as Passthrough API, are only supported through the OpenXR backend.\n\nPlease check our release notes for more details.\n\nReminder: you can switch the legacy and OpenXR backends at any time from Oculus > Tools > OpenXR menu options.", "Use OpenXR", "Cancel", "Release Notes");
                if (result == 0)
                {
                    break;
                }
                else if (result == 1)
                {
                    activateOpenXRPlugin = false;
                    break;
                }
                else if (result == 2)
                {
                    Application.OpenURL("https://developer.oculus.com/downloads/package/unity-integration/");
                }
                else
                {
                    UnityEngine.Debug.LogWarningFormat("Unrecognized result from DisplayDialogComplex: {0}", result);
                    break;
                }
            }
        }
#else
        bool activateOpenXRPlugin = false;
#endif
        if (activateOpenXRPlugin)
        {
            UnityEngine.Debug.Log("OVRPlugin with OpenXR backend is activated by default");
            if (!unityRunningInBatchmode)
            {
                EditorUtility.DisplayDialog("OVRPlugin", "OVRPlugin with OpenXR backend will be activated by default", "Ok");
            }
        }
        else
        {
            UnityEngine.Debug.Log("OVRPlugin with LibOVR/VRAPI backend is activated by default");
            if (!unityRunningInBatchmode)
            {
                EditorUtility.DisplayDialog("OVRPlugin", "OVRPlugin with LibOVR/VRAPI backend will be activated by default", "Ok");
            }
        }

        foreach (var kvp in pluginPkg.Plugins)
        {
            PluginPlatform platform = kvp.Key;
            string         path     = kvp.Value;

            if ((Directory.Exists(path + GetDisabledPluginSuffix())) || (File.Exists(path + GetDisabledPluginSuffix())))
            {
                string basePath        = GetCurrentProjectPath();
                string relPath         = path.Substring(basePath.Length + 1);
                string relDisabledPath = relPath + GetDisabledPluginSuffix();

                AssetDatabase.MoveAsset(relDisabledPath, relPath);
                AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate);

                PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter;
                if (pi == null)
                {
                    continue;
                }

                // Disable support for all platforms, then conditionally enable desired support below
                pi.SetCompatibleWithEditor(false);
                pi.SetCompatibleWithAnyPlatform(false);
                pi.SetCompatibleWithPlatform(BuildTarget.Android, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false);
                pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false);

                switch (platform)
                {
                case PluginPlatform.Android:
                    pi.SetCompatibleWithPlatform(BuildTarget.Android, !unityVersionSupportsAndroidUniversal);
                    if (!unityVersionSupportsAndroidUniversal)
                    {
                        pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7");
                    }
                    break;

                case PluginPlatform.AndroidUniversal:
                    if (!activateOpenXRPlugin)
                    {
                        pi.SetCompatibleWithPlatform(BuildTarget.Android, unityVersionSupportsAndroidUniversal);
                    }
                    break;

                case PluginPlatform.AndroidOpenXR:
                    if (activateOpenXRPlugin)
                    {
                        pi.SetCompatibleWithPlatform(BuildTarget.Android, unityVersionSupportsAndroidUniversal);
                    }
                    break;

                case PluginPlatform.OSXUniversal:
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, true);
                    pi.SetCompatibleWithEditor(true);
                    pi.SetEditorData("CPU", "AnyCPU");
                    pi.SetEditorData("OS", "OSX");
                    pi.SetPlatformData("Editor", "CPU", "AnyCPU");
                    pi.SetPlatformData("Editor", "OS", "OSX");
                    break;

                case PluginPlatform.Win:
                    pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true);
                    pi.SetCompatibleWithEditor(true);
                    pi.SetEditorData("CPU", "X86");
                    pi.SetEditorData("OS", "Windows");
                    pi.SetPlatformData("Editor", "CPU", "X86");
                    pi.SetPlatformData("Editor", "OS", "Windows");
                    break;

                case PluginPlatform.Win64:
                    if (!activateOpenXRPlugin)
                    {
                        pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true);
                        pi.SetCompatibleWithEditor(true);
                        pi.SetEditorData("CPU", "X86_64");
                        pi.SetEditorData("OS", "Windows");
                        pi.SetPlatformData("Editor", "CPU", "X86_64");
                        pi.SetPlatformData("Editor", "OS", "Windows");
                    }
                    break;

                case PluginPlatform.Win64OpenXR:
                    if (activateOpenXRPlugin)
                    {
                        pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true);
                        pi.SetCompatibleWithEditor(true);
                        pi.SetEditorData("CPU", "X86_64");
                        pi.SetEditorData("OS", "Windows");
                        pi.SetPlatformData("Editor", "CPU", "X86_64");
                        pi.SetPlatformData("Editor", "OS", "Windows");
                    }
                    break;

                default:
                    throw new ArgumentException("Attempted EnablePluginPackage() for unsupported BuildTarget: " + platform);
                }

                AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate);
            }
        }

        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
    }
 public SupportedPlatformAttribute(PluginPlatform platform)
 {
     this.Platform = platform;
 }