示例#1
0
        internal static void StackPopBuildConfiguration()
        {
            UnityEditor.BuildTarget currentTarget = EditorUserBuildSettings.activeBuildTarget;
            BuildTargetGroup        currentGroup  = EditorUserBuildSettings.selectedBuildTargetGroup;

            EditorUserBuildSettings.SwitchActiveBuildTargetAsync(currentGroup, currentTarget);
        }
        public override BuildResult Run(BuildContext context)
        {
            var target = context.GetValue <ClassicSharedData>().BuildTarget;

            if (target == BuildTarget.NoTarget)
            {
                return(context.Failure($"Invalid build target '{target.ToString()}'."));
            }

            if (EditorUserBuildSettings.activeBuildTarget == target)
            {
                return(context.Success());
            }

            var group = UnityEditor.BuildPipeline.GetBuildTargetGroup(target);

            if (EditorUserBuildSettings.SwitchActiveBuildTargetAsync(group, target))
            {
                return(context.Failure($"Editor's active Build Target needed to be switched to {target} (BuildTargetGroup {group}). Please wait for switch to complete and then build again."));
            }
            else
            {
                return(context.Failure($"Editor's active Build Target could not be switched to {target} (BuildTargetGroup {group}). Look in the console or the editor log for additional errors."));
            }
        }
示例#3
0
 /// <summary>
 /// 切换运行平台
 /// </summary>
 /// <param name="varTarget"></param>
 protected void SwitchApplication(BuildTarget varTarget)
 {
     if (EditorUserBuildSettings.activeBuildTarget != varTarget)
     {
         if (varTarget == BuildTarget.StandaloneWindows || varTarget == BuildTarget.StandaloneWindows64 || varTarget == BuildTarget.StandaloneOSX ||
             varTarget == BuildTarget.StandaloneLinux || varTarget == BuildTarget.StandaloneLinux64 || varTarget == BuildTarget.StandaloneLinuxUniversal)
         {
             EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, varTarget);
         }
         else if (varTarget == BuildTarget.Android)
         {
             EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Android, varTarget);
         }
         else if (varTarget == BuildTarget.WebGL)
         {
             EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WebGL, varTarget);
         }
         else if (varTarget == BuildTarget.iOS)
         {
             EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.iOS, varTarget);
         }
     }
     else
     {
         Builder();
     }
 }
        protected override void ApplySettings()
        {
            SaveMenuSettings();

            // Apply individual settings
            if (Values[ProjectSetting.BuildWsaUwp])
            {
                if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WSAPlayer)
                {
#if UNITY_2017_1_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
#else
                    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
#endif
                }
                else
                {
                    UpdateSettings(EditorUserBuildSettings.activeBuildTarget);
                }
            }
            else
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
            }
        }
    public static async void BuildAll()
    {
        string platformSwitchWarning = "This action will switch between platforms and build all addressable bundles. Do you want to continue?";

        if (!EditorUtility.DisplayDialog("Build for all platforms?", platformSwitchWarning, "Yes", "No"))
        {
            return;
        }

        Debug.Log("Building addressables for " + EditorUserBuildSettings.activeBuildTarget);
        await BuildAddressables();

        remainingBuildTargets = new List <BuildTarget>(buildTargets);

        // We have now built for this platform, so remove it from the remaining targets
        if (remainingBuildTargets.Contains(EditorUserBuildSettings.activeBuildTarget))
        {
            remainingBuildTargets.Remove(EditorUserBuildSettings.activeBuildTarget);
        }

        // Builds the remaining platforms
        foreach (BuildTarget buildTarget in remainingBuildTargets)
        {
            bool switched = EditorUserBuildSettings.SwitchActiveBuildTargetAsync(ConvertBuildTarget(buildTarget), buildTarget);
            if (switched == false)
            {
                Debug.Log("Exiting early: error during build of " + buildTarget);
                break;
            }
        }
    }
示例#6
0
        static void WaitForSwitchBuildTargetComplete()
        {
            var result = EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);

            if (result)
            {
                EditorApplication.update -= WaitForSwitchBuildTargetComplete;
            }
        }
示例#7
0
    private static void MenuButtonBuilds(BuildTarget buildTarget)
    {
        var StartBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
        var StartBuildTarget      = EditorUserBuildSettings.activeBuildTarget;

        isFromMenuPress = true;
        BuildForTarget(buildTarget);

        // Setting the current build target back to what it was
        if (StartBuildTarget != EditorUserBuildSettings.activeBuildTarget)
        {
            EditorUserBuildSettings.SwitchActiveBuildTargetAsync(StartBuildTargetGroup, StartBuildTarget);
        }
        isFromMenuPress = false;
    }
示例#8
0
        public static void BuildTarget(BuildTarget buildTarget)
        {
            /*	*/
            UnityEditor.BuildTarget currentTarget = EditorUserBuildSettings.activeBuildTarget;
            BuildTargetGroup        currentGroup  = EditorUserBuildSettings.selectedBuildTargetGroup;

            try
            {
                InternalBuildTarget(buildTarget);
            }
            finally
            {
                /*	*/
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(currentGroup, currentTarget);
            }
        }
示例#9
0
        public static bool Build()
        {
            var  savedTarget = EditorUserBuildSettings.activeBuildTarget;
            bool ok          = true;

            try
            {
                ok = Builder.Build(Storage.LoadOrCreateSettings(), (opts, progress, done) =>
                {
                    string message = done ?
                                     string.Format("Building {0} Done", opts.target.ToString()) :
                                     string.Format("Building {0}...", opts.target.ToString());
                    if (EditorUtility.DisplayCancelableProgressBar(
                            "Building project...",
                            message,
                            progress))
                    {
                        return(false); // cancel
                    }
                    return(true);
                });
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                EditorUtility.DisplayDialog("Build error", e.Message, "Close");
                ok = false;
            }

            EditorUtility.ClearProgressBar();
            if (ok)
            {
                Debug.Log("MultiBuild succeess");
            }
            else
            {
                EditorUtility.DisplayDialog("Cancelled", "Build cancelled before finishing.", "Close");
            }

            // Building can change the active target, can cause warnings or odd behaviour
            // Put it back to how it was
            if (EditorUserBuildSettings.activeBuildTarget != savedTarget)
            {
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(Builder.GroupForTarget(savedTarget), savedTarget);
            }
            return(ok);
        }
示例#10
0
        public static void BuildTargetScriptOnly(BuildTarget buildTarget)
        {
            /*	*/
            UnityEditor.BuildTarget currentTarget = EditorUserBuildSettings.activeBuildTarget;
            BuildTargetGroup        currentGroup  = EditorUserBuildSettings.selectedBuildTargetGroup;

            StackPushBuildConfiguration();
            try
            {
                InternalBuildScriptOnly(buildTarget);
            }
            finally
            {
                /*	*/
                StackPopBuildConfiguration();
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(currentGroup, currentTarget);
            }
        }
 public static void DrawBuildTargetSwitcher()
 {
     EditorGUILayout.LabelField("Active Build Target: " + EditorUserBuildSettings.activeBuildTarget);
     if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64 && GUILayout.Button("Switch Build Target to Android"))
     {
         if (EditorUtility.DisplayDialog("Build Target Switcher", "Are you sure you want to switch your build target to Android? This could take a while.", "Confirm", "Cancel"))
         {
             EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Android, BuildTarget.Android);
         }
     }
     if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android && GUILayout.Button("Switch Build Target to Windows"))
     {
         if (EditorUtility.DisplayDialog("Build Target Switcher", "Are you sure you want to switch your build target to Windows? This could take a while.", "Confirm", "Cancel"))
         {
             EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
         }
     }
 }
示例#12
0
        public static void BuildFromConfigScriptOnly(BuilderSettings settings)
        {
            /*	Remeber the state of the current build target.	*/
            UnityEditor.BuildTarget currentTarget = EditorUserBuildSettings.activeBuildTarget;
            BuildTargetGroup        currentGroup  = EditorUserBuildSettings.selectedBuildTargetGroup;

            try
            {
                for (int i = 0; i < settings.targets.Length; i++)
                {
                    InternalBuildScriptOnly(settings.targets[i]);
                }
            }
            finally
            {
                /*	Reset the state.	*/
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(currentGroup, currentTarget);
            }
        }
 protected override void ApplySettings()
 {
     // Apply individual settings
     if (Values[ProjectSetting.BuildWsaUwp])
     {
         if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WSAPlayer)
         {
             EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
         }
         else
         {
             UpdateSettings(EditorUserBuildSettings.activeBuildTarget);
         }
     }
     else
     {
         EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
     }
 }
示例#14
0
        void Build()
        {
            var savedTarget = EditorUserBuildSettings.activeBuildTarget;

            bool ok = true;

            try {
                ok = Builder.Build(Settings, (opts, progress, done) => {
                    string message = done ?
                                     string.Format("Building {0} Done", opts.target.ToString()) :
                                     string.Format("Building {0}...", opts.target.ToString());
                    if (EditorUtility.DisplayCancelableProgressBar(
                            "Building project...",
                            message,
                            progress))
                    {
                        return(false);    // cancel
                    }
                    return(true);
                });
            } catch (Exception e) {
                EditorUtility.DisplayDialog("Build error", e.Message, "Close");
                ok = false;
            }

            EditorUtility.ClearProgressBar();
            if (!ok)
            {
                EditorUtility.DisplayDialog("Cancelled", "Build cancelled before finishing.", "Close");
            }

            // Building can change the active target, can cause warnings or odd behaviour
            // Put it back to how it was
            if (EditorUserBuildSettings.activeBuildTarget != savedTarget)
            {
#if UNITY_5_6_OR_NEWER
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(Builder.GroupForTarget(savedTarget), savedTarget);
#else
                EditorUserBuildSettings.SwitchActiveBuildTarget(savedTarget);
#endif
            }
        }
示例#15
0
    public static void BuildAll()
    {
        HandleBuildConfig();
        var StartBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
        var StartBuildTarget      = EditorUserBuildSettings.activeBuildTarget;

        isFromMenuPress = true;

        var enabledBuilds = BuildConfig.BuildList.Where(b => b.IncludedInBuildAll == true)
                            .OrderByDescending(bi => bi.BuildTarget == StartBuildTarget).ThenByDescending(bi => bi.OverrideGroup);

        foreach (var buildItem in enabledBuilds)
        {
            Debug.Log($"BuildTargetGroup: {buildItem.BuildTargetGroup} and build target: {buildItem.BuildTarget}");
            BuildForTarget(buildItem.BuildTarget);
        }
        Debug.Log($"Finished build all switching back to: {StartBuildTarget}");
        EditorUserBuildSettings.SwitchActiveBuildTargetAsync(StartBuildTargetGroup, StartBuildTarget);
        isFromMenuPress = false;
    }
示例#16
0
 public void SwitchTarget()
 {
     UnityEngine.Debug.Log($"Switching build target from {EditorUserBuildSettings.activeBuildTarget} to {BuildTargetName}.");
     EditorUserBuildSettings.SwitchActiveBuildTargetAsync(GetTargetGroup(), GetBuildTarget());
 }
示例#17
0
        private static void InitializeSettins()
        {
            if (s_settings != null)
            {
                return;
            }

            s_settings = new List <IPropSetting>();

            //s_settings.Add(new RecommendedSetting<bool>()
            //{
            //    settingTitle = "Virtual Reality Supported",
            //    currentValueFunc = () => VIUSettingsEditor.virtualRealitySupported,
            //    setValueFunc = v => VIUSettingsEditor.virtualRealitySupported = v,
            //    recommendedValue = true,
            //});

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Virtual Reality Supported with OpenVR",
                skipCheckFunc    = () => !VIUSettingsEditor.canSupportOpenVR,
                currentValueFunc = () => VIUSettingsEditor.supportOpenVR,
                setValueFunc     = v => VIUSettingsEditor.supportOpenVR = v,
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Virtual Reality Supported with Oculus",
                skipCheckFunc    = () => !VIUSettingsEditor.canSupportOculus,
                currentValueFunc = () => VIUSettingsEditor.supportOculus,
                setValueFunc     = v => VIUSettingsEditor.supportOculus = v,
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Virtual Reality Supported with Daydream",
                skipCheckFunc    = () => !VIUSettingsEditor.canSupportDaydream,
                currentValueFunc = () => VIUSettingsEditor.supportDaydream,
                setValueFunc     = v => VIUSettingsEditor.supportDaydream = v,
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <BuildTarget>()
            {
                settingTitle     = "Build Target",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Standalone || VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Android,
                currentValueFunc = () => EditorUserBuildSettings.activeBuildTarget,
                setValueFunc     = v =>
                {
#if UNITY_2017_1_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
#elif UNITY_5_6_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
#else
                    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows64);
#endif
                },
                recommendedValue = BuildTarget.StandaloneWindows64,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Load Binding Config on Start",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = "You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.autoLoadBindingConfigOnStart,
                setValueFunc     = v => { VIUSettings.autoLoadBindingConfigOnStart = v; },
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Binding Interface Switch",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.BIND_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableBindingInterfaceSwitch,
                setValueFunc     = v => { VIUSettings.enableBindingInterfaceSwitch = v; },
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "External Camera Switch",
                skipCheckFunc    = () => !VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.EX_CAM_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableExternalCameraSwitch,
                setValueFunc     = v => { VIUSettings.enableExternalCameraSwitch = v; },
                recommendedValue = true,
            });

#if UNITY_5_3
            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Stereoscopic Rendering",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected,
                currentValueFunc = () => PlayerSettings.stereoscopic3D,
                setValueFunc     = v => PlayerSettings.stereoscopic3D = v,
                recommendedValue = false,
            });
#endif

#if UNITY_5_3 || UNITY_5_4
            s_settings.Add(new RecommendedSetting <RenderingPath>()
            {
                settingTitle        = "Rendering Path",
                skipCheckFunc       = () => VRModule.isSteamVRPluginDetected,
                recommendBtnPostfix = "required for MSAA",
                currentValueFunc    = () => PlayerSettings.renderingPath,
                setValueFunc        = v => PlayerSettings.renderingPath = v,
                recommendedValue    = RenderingPath.Forward,
            });

            // Unity 5.3 doesn't have SplashScreen for VR
            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Show Unity Splash Screen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !InternalEditorUtility.HasPro(),
                currentValueFunc = () => PlayerSettings.showUnitySplashScreen,
                setValueFunc     = v => PlayerSettings.showUnitySplashScreen = v,
                recommendedValue = false,
            });
#endif

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle         = "GPU Skinning",
                skipCheckFunc        = () => VRModule.isSteamVRPluginDetected,
                currentValueFunc     = () => PlayerSettings.gpuSkinning,
                setValueFunc         = v => PlayerSettings.gpuSkinning = v,
                recommendedValueFunc = () => !VIUSettingsEditor.supportWaveVR,
            });

            s_settings.Add(new RecommendedSetting <Vector2>()
            {
                settingTitle     = "Default Screen Size",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => new Vector2(PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight),
                setValueFunc     = v => { PlayerSettings.defaultScreenWidth = (int)v.x; PlayerSettings.defaultScreenHeight = (int)v.y; },
                recommendedValue = new Vector2(1024f, 768f),
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Run In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.runInBackground,
                setValueFunc     = v => PlayerSettings.runInBackground = v,
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <ResolutionDialogSetting>()
            {
                settingTitle     = "Display Resolution Dialog",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.displayResolutionDialog,
                setValueFunc     = v => PlayerSettings.displayResolutionDialog = v,
                recommendedValue = ResolutionDialogSetting.HiddenByDefault,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Resizable Window",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.resizableWindow,
                setValueFunc     = v => PlayerSettings.resizableWindow = v,
                recommendedValue = true,
            });

#if !UNITY_2018_1_OR_NEWER
            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Default Is Fullscreen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.defaultIsFullScreen,
                setValueFunc     = v => PlayerSettings.defaultIsFullScreen = v,
                recommendedValue = false,
            });

            s_settings.Add(new RecommendedSetting <D3D11FullscreenMode>()
            {
                settingTitle     = "D3D11 Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.d3d11FullscreenMode,
                setValueFunc     = v => PlayerSettings.d3d11FullscreenMode = v,
                recommendedValue = D3D11FullscreenMode.FullscreenWindow,
            });
#else
            s_settings.Add(new RecommendedSetting <FullScreenMode>()
            {
                settingTitle     = "Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.fullScreenMode,
                setValueFunc     = v => PlayerSettings.fullScreenMode = v,
                recommendedValue = FullScreenMode.FullScreenWindow,
            });
#endif

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Visible In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => PlayerSettings.visibleInBackground,
                setValueFunc     = v => PlayerSettings.visibleInBackground = v,
                recommendedValue = true,
            });

            s_settings.Add(new RecommendedSetting <ColorSpace>()
            {
                settingTitle        = "Color Space",
                skipCheckFunc       = () => VRModule.isSteamVRPluginDetected,
                recommendBtnPostfix = "requires reloading scene",
                currentValueFunc    = () => PlayerSettings.colorSpace,
                setValueFunc        = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        PlayerSettings.colorSpace = v;
                        PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
                        var listChanged = false;
                        var apiList     = ListPool <GraphicsDeviceType> .Get();
                        apiList.AddRange(PlayerSettings.GetGraphicsAPIs(BuildTarget.Android));
                        if (!apiList.Contains(GraphicsDeviceType.OpenGLES3))
                        {
                            apiList.Add(GraphicsDeviceType.OpenGLES3); listChanged = true;
                        }
#if UNITY_5_5_OR_NEWER
                        // FIXME: Daydream SDK currently not support Vulkan API
                        if (apiList.Remove(GraphicsDeviceType.Vulkan))
                        {
                            listChanged = true;
                        }
#endif
                        if (apiList.Remove(GraphicsDeviceType.OpenGLES2))
                        {
                            listChanged = true;
                        }
                        if (listChanged)
                        {
                            PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, apiList.ToArray());
                        }
                        ListPool <GraphicsDeviceType> .Release(apiList);
                    }
                    else
                    {
                        PlayerSettings.colorSpace = v;
                    }
                },
                recommendedValue = ColorSpace.Linear,
            });

            s_settings.Add(new RecommendedSetting <UIOrientation>()
            {
                settingTitle     = "Default Interface Orientation",
                skipCheckFunc    = () => !VIUSettingsEditor.supportWaveVR || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Android,
                currentValueFunc = () => PlayerSettings.defaultInterfaceOrientation,
                setValueFunc     = v => PlayerSettings.defaultInterfaceOrientation = v,
                recommendedValue = UIOrientation.LandscapeLeft,
            });

            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle  = "Multithreaded Rendering",
                skipCheckFunc = () => !VIUSettingsEditor.supportWaveVR || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Android,
#if UNITY_2017_2_OR_NEWER
                currentValueFunc = () => PlayerSettings.MTRendering,
                setValueFunc     = v => PlayerSettings.MTRendering = v,
#else
                currentValueFunc = () => PlayerSettings.mobileMTRendering,
                setValueFunc     = v => PlayerSettings.mobileMTRendering = v,
#endif
                recommendedValue = true,
            });

#if UNITY_5_4_OR_NEWER
            s_settings.Add(new RecommendedSetting <bool>()
            {
                settingTitle     = "Graphic Jobs",
                skipCheckFunc    = () => !VIUSettingsEditor.supportWaveVR || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Android,
                currentValueFunc = () => PlayerSettings.graphicsJobs,
                setValueFunc     = v => PlayerSettings.graphicsJobs = v,
                recommendedValue = true,
            });
#endif
        }
示例#18
0
        public OpenVRRecommendedSettings()
        {
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Virtual Reality Supported with OpenVR",
                skipCheckFunc    = () => !VIUSettingsEditor.canSupportOpenVR,
                currentValueFunc = () => VIUSettingsEditor.supportOpenVR,
                setValueFunc     = v => VIUSettingsEditor.supportOpenVR = v,
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <BuildTarget>()
            {
                settingTitle     = "Build Target",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => EditorUserBuildSettings.activeBuildTarget,
                setValueFunc     = v =>
                {
#if UNITY_2017_1_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, v);
#elif UNITY_5_6_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, v);
#else
                    EditorUserBuildSettings.SwitchActiveBuildTarget(v);
#endif
                },
                recommendedValue = BuildTarget.StandaloneWindows64,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Load Binding Config on Start",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = "You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.autoLoadBindingConfigOnStart,
                setValueFunc     = v => { VIUSettings.autoLoadBindingConfigOnStart = v; },
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Binding Interface Switch",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.BIND_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableBindingInterfaceSwitch,
                setValueFunc     = v => { VIUSettings.enableBindingInterfaceSwitch = v; },
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "External Camera Switch",
                skipCheckFunc    = () => !VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.EX_CAM_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableExternalCameraSwitch,
                setValueFunc     = v => { VIUSettings.enableExternalCameraSwitch = v; },
                recommendedValue = true,
            });

#if UNITY_5_3
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Stereoscopic Rendering",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.stereoscopic3D,
                setValueFunc     = v => PlayerSettings.stereoscopic3D = v,
                recommendedValue = false,
            });
#endif

#if UNITY_5_3 || UNITY_5_4
            Add(new VIUVersionCheck.RecommendedSetting <RenderingPath>()
            {
                settingTitle        = "Rendering Path",
                skipCheckFunc       = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                recommendBtnPostfix = "required for MSAA",
                currentValueFunc    = () => PlayerSettings.renderingPath,
                setValueFunc        = v => PlayerSettings.renderingPath = v,
                recommendedValue    = RenderingPath.Forward,
            });

            // Unity 5.3 doesn't have SplashScreen for VR
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Show Unity Splash Screen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !InternalEditorUtility.HasPro() || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.showUnitySplashScreen,
                setValueFunc     = v => PlayerSettings.showUnitySplashScreen = v,
                recommendedValue = false,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "GPU Skinning",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.gpuSkinning,
                setValueFunc     = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        VIUSettingsEditor.SetGraphicsAPI(BuildTarget.Android, GraphicsDeviceType.OpenGLES3);
                    }
                    PlayerSettings.gpuSkinning = v;
                },
                recommendedValueFunc = () => !VIUSettingsEditor.supportWaveVR,
            });

            Add(new VIUVersionCheck.RecommendedSetting <Vector2>()
            {
                settingTitle     = "Default Screen Size",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => new Vector2(PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight),
                setValueFunc     = v => { PlayerSettings.defaultScreenWidth = (int)v.x; PlayerSettings.defaultScreenHeight = (int)v.y; },
                recommendedValue = new Vector2(1024f, 768f),
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Run In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.runInBackground,
                setValueFunc     = v => PlayerSettings.runInBackground = v,
                recommendedValue = true,
            });

#if !UNITY_2019_2_OR_NEWER
            Add(new VIUVersionCheck.RecommendedSetting <ResolutionDialogSetting>()
            {
                settingTitle     = "Display Resolution Dialog",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.displayResolutionDialog,
                setValueFunc     = v => PlayerSettings.displayResolutionDialog = v,
                recommendedValue = ResolutionDialogSetting.HiddenByDefault,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Resizable Window",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.resizableWindow,
                setValueFunc     = v => PlayerSettings.resizableWindow = v,
                recommendedValue = true,
            });

#if !UNITY_2018_1_OR_NEWER
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Default Is Fullscreen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.defaultIsFullScreen,
                setValueFunc     = v => PlayerSettings.defaultIsFullScreen = v,
                recommendedValue = false,
            });

            Add(new VIUVersionCheck.RecommendedSetting <D3D11FullscreenMode>()
            {
                settingTitle     = "D3D11 Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.d3d11FullscreenMode,
                setValueFunc     = v => PlayerSettings.d3d11FullscreenMode = v,
                recommendedValue = D3D11FullscreenMode.FullscreenWindow,
            });
#else
            Add(new VIUVersionCheck.RecommendedSetting <FullScreenMode>()
            {
                settingTitle     = "Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.fullScreenMode,
                setValueFunc     = v => PlayerSettings.fullScreenMode = v,
                recommendedValue = FullScreenMode.FullScreenWindow,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Visible In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.visibleInBackground,
                setValueFunc     = v => PlayerSettings.visibleInBackground = v,
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <ColorSpace>()
            {
                settingTitle        = "Color Space",
                skipCheckFunc       = () => (VRModule.isSteamVRPluginDetected && VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Standalone) || !VIUSettingsEditor.supportAnyVR,
                recommendBtnPostfix = "requires reloading scene",
                currentValueFunc    = () => PlayerSettings.colorSpace,
                setValueFunc        = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        VIUSettingsEditor.SetGraphicsAPI(BuildTarget.Android, GraphicsDeviceType.OpenGLES3);
                    }
                    PlayerSettings.colorSpace = v;
                },
                recommendedValue = ColorSpace.Linear,
            });
#if VIU_STEAMVR_2_0_0_OR_NEWER
            Add(new RecommendedSteamVRInputFileSettings());
#endif
        }
示例#19
0
        private void ApplySelectedConfiguration(MixedRealityProjectConfiguration selectedMRConfiguration)
        {
            bool             remoting = false;
            BuildTargetGroup targetGroup;

            switch (selectedMRConfiguration)
            {
            case MixedRealityProjectConfiguration.RunNativelyOnHL2:
                targetGroup = BuildTargetGroup.WSA;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
                EditorUserBuildSettings.wsaBuildAndRunDeployTarget = WSABuildAndRunDeployTarget.DevicePortal;
                EditorUserBuildSettings.wsaArchitecture            = "ARM64";
                break;

            case MixedRealityProjectConfiguration.RunNativelyOnPCVR:
                targetGroup = BuildTargetGroup.Standalone;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                break;

            case MixedRealityProjectConfiguration.RunRemotelyOnUWP:
                remoting    = true;
                targetGroup = BuildTargetGroup.WSA;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
                EditorUserBuildSettings.wsaBuildAndRunDeployTarget = WSABuildAndRunDeployTarget.LocalMachine;
                EditorUserBuildSettings.wsaArchitecture            = "Intel64";
                // Player Capabilities
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.InternetClient, true);
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.InternetClientServer, true);
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.PrivateNetworkClientServer, true);
                break;

            case MixedRealityProjectConfiguration.RunRemotelyOnWin32:
                remoting    = true;
                targetGroup = BuildTargetGroup.Standalone;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                break;

            default:
                return;
            }

            const string AppRemotingPlugin  = "Microsoft.MixedReality.OpenXR.Remoting.AppRemotingPlugin";
            Type         appRemotingFeature = typeof(AppRemoting).Assembly.GetType(AppRemotingPlugin);

            if (appRemotingFeature == null)
            {
                Debug.LogError($"Could not find {AppRemotingPlugin}. Has this class been removed or renamed?");
                return;
            }

            FeatureHelpers.RefreshFeatures(targetGroup);
            OpenXRFeature feature = OpenXRSettings.ActiveBuildTargetInstance.GetFeature(appRemotingFeature);

            if (feature == null)
            {
                Debug.LogError($"Could not load {AppRemotingPlugin} as an OpenXR feature. Has this class been removed or renamed?");
                return;
            }
            feature.enabled = remoting;

            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(targetGroup);

            if (settings != null)
            {
                settings.InitManagerOnStart = !remoting;
            }
            Debug.Log($"Set up complete for {selectedMRConfiguration}");
        }
示例#20
0
        protected virtual void OnGUI()
        {
            GUILayout.BeginVertical();

            //Draw the Title
            GUILayout.Space(10);
            GUILayout.Label("<color=red>Lenovo MirageAR Settings</color>", m_TitleStyle);
            //Image Title
            //var resourcePath = GetResourcePath();
            //var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "lenovo_logo_red.png");
            //var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
            //if (logo)
            //    GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);

            //Draw help text
            EditorGUILayout.HelpBox("Recommended project settings for LenovoMirageAR!", MessageType.Warning);
#if !UNITY_2017_2
            EditorGUILayout.HelpBox("Recommended Use Unity 2017.2.0f3!", MessageType.Error);
#endif

            DrawSeparator();

            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);

            //1,Check Build Target
            #region Build Target Setting

            EditorGUILayout.LabelField("Build Target Setting", m_HeaderStyle);

            GUILayout.Space(10);

            BeginGroup();

            EditorGUILayout.BeginHorizontal();

            if (s_BuildTargetNames == null)
            {
                BuildTargetTypes();
            }

            buildTargetPopupIndex = EditorGUILayout.Popup("Build Target", buildTargetPopupIndex, s_BuildTargetNames);

            switch (buildTargetPopupIndex)
            {
            case 0:
                if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_Android)
                {
                    if (GUILayout.Button("Switch", GUILayout.Width(80)))
                    {
                        EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Android, recommended_BuildTarget_Android);
                    }
                }
                break;

            case 1:
                if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_iOS)
                {
                    if (GUILayout.Button("Switch", GUILayout.Width(80)))
                    {
                        EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.iOS, recommended_BuildTarget_iOS);
                    }
                }
                break;

            default:
                break;
            }

            GUILayout.Space(10);

            GUILayout.EndHorizontal();

            EndGroup();

            if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_Android && EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget_iOS)
            {
                //Draw help text
                EditorGUILayout.HelpBox("LenovoMirageAR Only Support Anndroid&iOS,Please Switch To Target Platform First!", MessageType.Error);

                EditorGUILayout.EndScrollView();
                GUILayout.EndVertical();
                return;
            }

            #endregion Build Target Setting

            int numItems = 0;

            DrawSeparator();

            EditorGUILayout.LabelField("Build Settings", m_HeaderStyle);

            GUILayout.Space(10);

            BeginGroup();

            //2,Check Build Setting for Android
            if (EditorUserBuildSettings.activeBuildTarget == recommended_BuildTarget_Android)
            {
                //Orientation Right
                if (!CheckOrientation())
                {
                    ++numItems;

                    GUILayout.Label(defaultOrientation + string.Format(currentValue, PlayerSettings.defaultInterfaceOrientation));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_defaultOrientation)))
                    {
                        SetOrientation();
                    }

                    GUILayout.EndHorizontal();
                }

                //Show SplashScreen
                if (!CheckShowSplashScreen())
                {
                    ++numItems;

                    GUILayout.Label(showSplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_showSplashScreen)))
                    {
                        SetShowSplashScreen();
                    }

                    GUILayout.EndHorizontal();
                }

                //Android min SDK
                if (!CheckAndroidMinSDK())
                {
                    ++numItems;

                    GUILayout.Label(AndroidMinSDK + string.Format(currentValue, PlayerSettings.Android.minSdkVersion));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_AndroidMinSDK)))
                    {
                        SetAndroidMinSDK();
                    }

                    GUILayout.EndHorizontal();
                }

                //Andrid Target SDK
                if (!CheckAndroidTargetSDK())
                {
                    ++numItems;

                    GUILayout.Label(AndroidTargetSDK + string.Format(currentValue, PlayerSettings.Android.targetSdkVersion));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_AndroidTargetSDK)))
                    {
                        SetAndroidTargetSDK();
                    }

                    GUILayout.EndHorizontal();
                }

                //XR Setting
                if (!CheckXRSettings(BuildTargetGroup.Android))
                {
                    ++numItems;

                    string value = string.Empty;
                    if (VREditor.GetVREnabledOnTargetGroup(BuildTargetGroup.Android))
                    {
                        value = "VR Enalbe;Devices=";
                        string[] currentSupportDevices = VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android);
                        if (currentSupportDevices.Length == 0)
                        {
                            value += "Empty";
                        }
                        else
                        {
                            value += string.Join(",", currentSupportDevices);
                        }
                    }
                    else
                    {
                        value = "VR Disable";
                    }

                    GUILayout.Label(XRSettings + string.Format(currentValue, value));

                    GUILayout.BeginHorizontal();

                    string recommend = recommended_VirtualRealitySDKs_First + "," + recommended_VirtualRealitySDKs_Second;
                    if (GUILayout.Button(string.Format(useRecommended, recommend)))
                    {
                        SetXRSettings(BuildTargetGroup.Android);
                    }

                    GUILayout.EndHorizontal();
                }

                //Scrip DefineSymbols
                if (!CheckScriptingDefineSymbols(BuildTargetGroup.Android))
                {
                    ++numItems;

                    GUILayout.Label(string.Format("{0} miss {1}", ScriptingDefineSymbols, recommended_VRTKMirageScriptingDefineSymbols));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_VRTKMirageScriptingDefineSymbols)))
                    {
                        SetScriptingDefineSymbols(BuildTargetGroup.Android);
                    }

                    GUILayout.EndHorizontal();
                }

                //Start Scene
                if (!CheckStartScene())
                {
                    ++numItems;

                    string labelText = "";
                    if (EditorBuildSettings.scenes.Length == 0)
                    {
                        labelText = string.Format(currentValue, "null");
                    }
                    else if (EditorBuildSettings.scenes[0].path != recommended_StartScene)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path);
                    }
                    else if (!EditorBuildSettings.scenes[0].enabled)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path + " disable");
                    }

                    GUILayout.Label(StartScene + labelText);

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_StartScene)))
                    {
                        SetStartScene();
                    }

                    GUILayout.EndHorizontal();
                }
            }
            else if (EditorUserBuildSettings.activeBuildTarget == recommended_BuildTarget_iOS) //2,Check Build Setting for iOS
            {
                //Orientation Right
                if (PlayerSettings.defaultInterfaceOrientation != recommended_defaultOrientation)
                {
                    ++numItems;

                    GUILayout.Label(defaultOrientation + string.Format(currentValue, PlayerSettings.defaultInterfaceOrientation));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_defaultOrientation)))
                    {
                        PlayerSettings.defaultInterfaceOrientation = recommended_defaultOrientation;
                    }

                    GUILayout.EndHorizontal();
                }

                //Show SplashScreen
                if (!CheckShowSplashScreen())
                {
                    ++numItems;

                    GUILayout.Label(showSplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_showSplashScreen)))
                    {
                        SetShowSplashScreen();
                    }

                    GUILayout.EndHorizontal();
                }

                //XR Setting
                if (!(CheckXRSettings(BuildTargetGroup.iOS)))
                {
                    ++numItems;

                    string value = string.Empty;
                    if (VREditor.GetVREnabledOnTargetGroup(BuildTargetGroup.iOS))
                    {
                        value = "VR Enalbe;Devices=";
                        string[] currentSupportDevices = VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.iOS);
                        if (currentSupportDevices.Length == 0)
                        {
                            value += "Empty";
                        }
                        else
                        {
                            value += string.Join(",", currentSupportDevices);
                        }
                    }
                    else
                    {
                        value = "VR Disable";
                    }

                    GUILayout.Label(XRSettings + string.Format(currentValue, value));

                    GUILayout.BeginHorizontal();

                    string recommend = recommended_VirtualRealitySDKs_First + "," + recommended_VirtualRealitySDKs_Second;
                    if (GUILayout.Button(string.Format(useRecommended, recommend)))
                    {
                        VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup.iOS, true);

                        VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.iOS, VRDevice);
                    }

                    GUILayout.EndHorizontal();
                }

                //Scrip DefineSymbols
                if (!CheckScriptingDefineSymbols(BuildTargetGroup.iOS))
                {
                    ++numItems;

                    GUILayout.Label(string.Format("{0} miss {1}", ScriptingDefineSymbols, recommended_VRTKMirageScriptingDefineSymbols));

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_VRTKMirageScriptingDefineSymbols)))
                    {
                        SetScriptingDefineSymbols(BuildTargetGroup.iOS);
                    }

                    GUILayout.EndHorizontal();
                }

                //Start Scene
                if (!CheckStartScene())
                {
                    ++numItems;

                    string labelText = "";
                    if (EditorBuildSettings.scenes.Length == 0)
                    {
                        labelText = string.Format(currentValue, "null");
                    }
                    else if (EditorBuildSettings.scenes[0].path != recommended_StartScene)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path);
                    }
                    else if (!EditorBuildSettings.scenes[0].enabled)
                    {
                        labelText = string.Format(currentValue, EditorBuildSettings.scenes[0].path + " disable");
                    }

                    GUILayout.Label(StartScene + labelText);

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(string.Format(useRecommended, recommended_StartScene)))
                    {
                        SetStartScene();
                    }

                    GUILayout.EndHorizontal();
                }
            }

            EndGroup();

            if (numItems > 0)
            {
                EditorGUILayout.EndScrollView();

                GUILayout.EndVertical();

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Accept All"))
                {
                    SetBuildSettings();
                }

                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.Label("<color=green>Set Correctly!</color>", m_TitleStyle);

                EditorGUILayout.EndScrollView();

                GUILayout.EndVertical();

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Close"))
                {
                    Close();
                }

                GUILayout.EndHorizontal();
            }
        }
示例#21
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        buildName = EditorGUILayout.TextField("Build Name:", buildName);
        copyFiles = EditorGUILayout.Toggle("Include Config Files: ", copyFiles);
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Change Log:");
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(250.0f), GUILayout.Height(250.0f));
        changeLogText  = EditorGUILayout.TextArea(changeLogText, GUILayout.Width(250.0f), GUILayout.Height(250.0f));
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical();
        EditorGUI.LabelField(new Rect(275.0f, 40.0f, 100.0f, 25.0f), "Build Platform:");

        GUILayout.BeginArea(new Rect(275.0f, 65.0f, 250.0f, 250.0f));
        //Windows x64
        if (GUILayout.Button(buildTargetGroups[0].ToString() + " (x64)"))
        {
            EditorUserBuildSettings.SwitchActiveBuildTargetAsync(buildTargetGroups[0], BuildTarget.StandaloneWindows64);
        }
        //Windows x32
        if (GUILayout.Button(buildTargetGroups[0].ToString() + " (x32)"))
        {
            EditorUserBuildSettings.SwitchActiveBuildTargetAsync(buildTargetGroups[0], BuildTarget.StandaloneWindows);
        }
        //Android
        if (GUILayout.Button(buildTargetGroups[1].ToString()))
        {
            EditorUserBuildSettings.SwitchActiveBuildTargetAsync(buildTargetGroups[1], BuildTarget.Android);
        }
        //iOS
        if (GUILayout.Button(buildTargetGroups[2].ToString()))
        {
            EditorUserBuildSettings.SwitchActiveBuildTargetAsync(buildTargetGroups[2], BuildTarget.iOS);
        }
        GUILayout.EndArea();

        EditorGUILayout.EndVertical();

        EditorGUILayout.EndHorizontal();

        EditorUtility.SetDirty(this);

        Repaint();

        if (GUILayout.Button("Build", GUILayout.Width(100.0f), GUILayout.Height(25.0f)))
        {
            AutoBuild.BuildProjectCustomSettings(BuildOptions.ShowBuiltPlayer, buildName, copyFiles, changeLogText);
        }

        if (GUILayout.Button("Build and Run", GUILayout.Width(100.0f), GUILayout.Height(25.0f)))
        {
            AutoBuild.BuildProjectCustomSettings(BuildOptions.AutoRunPlayer, buildName, copyFiles, changeLogText);
        }
    }