public void OnPreprocessBuild(BuildTarget target, string path)
    {
#endif
#if UNITY_ANDROID || (UNITY_IPHONE || UNITY_IOS)
        string identifierError = appIdentifierSetup() ? "" : "\nThe Megacool app identifier has not been set";
        string appConfigError  = appConfigSetup(target) ? "" : "\nThe Megacool " + target.ToString() + " key has not been set";
        string errorMessage    = identifierError + appConfigError + "\nGo to 'Megacool->Configuration' to setup configuation and rebuild application";

        if (!appIdentifierSetup() || !appConfigSetup(target))
        {
            EditorUtility.DisplayDialog("Megacool Configuration Error", errorMessage, "Ok");
            Debug.LogError("Megacool Configuration Error" + errorMessage);
        }
#endif

#if UNITY_ANDROID
        AndroidSdkVersions minSupportedApiVersion = AndroidSdkVersions.AndroidApiLevel16;
        AndroidSdkVersions apiVersion             = PlayerSettings.Android.minSdkVersion;
        if (apiVersion < minSupportedApiVersion)
        {
            string minApiError = "\nThe application's minimum API version (" + apiVersion + ") is less than the required API version by Megacool (" +
                                 minSupportedApiVersion + ")\n\nGo to 'Edit->Project Settings->Player' to set the minimum API version and rebuild application";

            EditorUtility.DisplayDialog("Megacool API Error", minApiError, "Ok");
            Debug.LogError("Megacool Configuration Error" + minApiError);
        }
#endif
        MegacoolEditor.WarnIfAndroidAndVulkanEnabled();
    }
 private OptionSet DefineOptionSet()
 {
     return(new OptionSet()
            .Add("scriptingbackend=",
                 "Scripting backend to use. IL2CPP is default. Values: IL2CPP, Mono",
                 ParseScriptingBackend)
            .Add("enabledxrtargets=",
                 "XR targets to enable in XR enabled players, separated by ';'. Values: \r\n\"Oculus\"\r\n\"OpenVR\"\r\n\"cardboard\"\r\n\"daydream\"",
                 xrTargets => enabledXrTargets = ParseEnabledXrTargets(xrTargets))
            .Add("playergraphicsapi=", "Optionally force player to use the specified GraphicsDeviceType. Direct3D11, OpenGLES2, OpenGLES3, PlayStationVita, PlayStation4, XboxOne, Metal, OpenGLCore, Direct3D12, N3DS, Vulkan, Switch, XboxOneD3D12",
                 (GraphicsDeviceType graphicsDeviceType) => playerGraphicsApi = graphicsDeviceType)
            .Add("stereoRenderingPath=", "StereoRenderingPath to use for XR enabled players. MultiPass, SinglePass, Instancing. Default is SinglePass.",
                 stereoRenderingPathMode => stereoRenderingPath = TryParse <StereoRenderingPath>(stereoRenderingPathMode))
            .Add("mtRendering", "Enable or disable multithreaded rendering. Enabled is default. Use option to enable, or use option and append '-' to disable.",
                 option => mtRendering = option != null)
            .Add("graphicsJobs", "Enable graphics jobs rendering. Disabled is default. Use option to enable, or use option and append '-' to disable.",
                 option => graphicsJobs = option != null)
            .Add("minimumandroidsdkversion=", "Minimum Android SDK Version to use. Default is AndroidApiLevel24. Use for deployment and running tests on Android device.",
                 minAndroidSdkVersion => minimumAndroidSdkVersion = TryParse <AndroidSdkVersions>(minAndroidSdkVersion))
            .Add("targetandroidsdkversion=", "Target Android SDK Version to use. Default is AndroidApiLevel24. Use for deployment and running tests on Android device.",
                 trgtAndroidSdkVersion => targetAndroidSdkVersion = TryParse <AndroidSdkVersions>(trgtAndroidSdkVersion))
            .Add("appleDeveloperTeamID=", "Apple Developer Team ID. Use for deployment and running tests on iOS device.",
                 appleTeamId => appleDeveloperTeamId = appleTeamId)
            .Add("iOSProvisioningProfileID=", "iOS Provisioning Profile ID. Use for deployment and running tests on iOS device.",
                 id => iOsProvisioningProfileId = id));
 }
    static void setPlayerSettings()
    {
        IDictionary <string, object> appsDbDict = GetAppsDBJSON();

        string minSDKversion = ((appsDbDict["google"] as IDictionary <string, object>)["minSDKversion"] as string);

        UnityEngine.Debug.Log("Set minSDKversion to: " + minSDKversion);
        AndroidSdkVersions androidMinSdkVersion = (AndroidSdkVersions)Enum.Parse(typeof(AndroidSdkVersions), minSDKversion);

        if (!System.String.IsNullOrEmpty(minSDKversion))
        {
            PlayerSettings.Android.minSdkVersion = androidMinSdkVersion;
        }

        string targetSDKversion = ((appsDbDict["google"] as IDictionary <string, object>)["targetSDKVersion"] as string);

        UnityEngine.Debug.Log("Set targetSDKversion to: " + targetSDKversion);
        AndroidSdkVersions androidTargetSdkVersion = (AndroidSdkVersions)Enum.Parse(typeof(AndroidSdkVersions), targetSDKversion);

        if (!System.String.IsNullOrEmpty(targetSDKversion))
        {
            PlayerSettings.Android.targetSdkVersion = androidTargetSdkVersion;
        }

        EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
        AssetDatabase.SaveAssets();
    }
Beispiel #4
0
        public virtual bool Initialize(BuildToolLogger buildToolLogger)
        {
            // Cache information that is only accessible from the main thread.
            _isGradleBuild = EditorUserBuildSettings.androidBuildSystem == AndroidBuildSystem.Gradle;
            _minSdkVersion = PlayerSettings.Android.minSdkVersion;
            _packageName   = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
            _versionCode   = PlayerSettings.Android.bundleVersionCode;
            _versionName   = PlayerSettings.bundleVersion;

            _assetPackManifestTransformers = AssetPackManifestTransformerRegistry.Registry.ConstructInstances();
            var initializedManifestTransformers = true;

            foreach (var transformer in _assetPackManifestTransformers)
            {
                initializedManifestTransformers &= transformer.Initialize(buildToolLogger);
            }

            return(CheckUnityVersion(buildToolLogger) &&
                   initializedManifestTransformers &&
                   _androidAssetPackagingTool.Initialize(buildToolLogger) &&
                   _androidBuilder.Initialize(buildToolLogger) &&
                   _jarSigner.Initialize(buildToolLogger) &&
                   _bundletool.Initialize(buildToolLogger) &&
                   _zipUtils.Initialize(buildToolLogger));
        }
        /// <summary>
        /// Overrides the postprocess method to revert the AndroidProductInfo changes to the PlayerSettings.
        /// <summary>
        override public void Postprocess(string buildPath)
        {
            base.Postprocess(buildPath);

            AndroidProductInfo info;

            info = PlatformUtil.GetSettings <AndroidProductInfo>();

            if (info)
            {
                // restore player settings
                PlayerSettings.productName = this.ProductName;
                PlayerSettings.SetApplicationIdentifier(BuildTargetGroup, this.BundleIdentifier);
                PlayerSettings.bundleVersion             = this.BundleVersion;
                PlayerSettings.Android.bundleVersionCode = this.BundleVersionCode;
                PlayerSettings.Android.minSdkVersion     = this.SdkVersion;

                // clear player settings
                this.ProductName       = null;
                this.BundleIdentifier  = null;
                this.BundleVersion     = null;
                this.BundleVersionCode = 0;
                this.SdkVersion        = default(AndroidSdkVersions);
            }
        }
        public string GetMaxAspectRatio(AndroidSdkVersions targetSdkVersion)
        {
            if (AspectRatioMode == AspectRatioMode.Custom)
            {
                return(CustomAspectRatio.ToString(CultureInfo.InvariantCulture));
            }

            if (targetSdkVersion < AndroidSdkVersions.AndroidApiLevel26)
            {
                // in API level 25 and lower the default maximum aspect ratio is 1.86
                // return 2.1 if super wide screen aspect ratio should be supported
                if (AspectRatioMode == AspectRatioMode.SuperWideScreen)
                {
                    return("2.1");
                }
            }
            else
            {
                // since API level 26 the default maximum aspect ratio is the native aspect ratio of the device
                // return 1.86 if only regular wide screen aspect ratio should be supported
                if (AspectRatioMode == AspectRatioMode.LegacyWideScreen)
                {
                    return("1.86");
                }
            }

            // don't specify max aspect ratio, use default value for the API level
            return("");
        }
        /// <summary>
        /// Returns true if the specified SDK version is less than 21 and false if it's greater than or equal to 21.
        ///
        /// This method can be used (along with the existence of install-time asset packs) to determine whether this
        /// app requires <see cref="BundletoolConfig.StandaloneConfig"/> to support pre-L devices.
        /// </summary>
        public static bool IsSdkVersionPreLollipop(AndroidSdkVersions sdkVersion)
        {
#if UNITY_2021_2_OR_NEWER
            // The minimum API level supported by Unity 2021.2+ is 22.
            return(false);
#else
            return(sdkVersion < AndroidSdkVersions.AndroidApiLevel21);
#endif
        }
Beispiel #8
0
        private int ResolveIndex(List <int> choices, AndroidSdkVersions apiLevel)
        {
            for (int i = 0; i < choices.Count; i++)
            {
                if (choices[i] == (int)apiLevel)
                {
                    return(i);
                }
            }

            return(0);
        }
        private void MinSdkCheck()
        {
#if !UNITY_2021_2_OR_NEWER
            // API level 21 not supported since 2021.2, need to check for prior releases
            const AndroidSdkVersions kMinAndroidSdk = AndroidSdkVersions.AndroidApiLevel21;

            if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel21)
            {
                throw new NotSupportedException(string.Format("Minimum Android API level supported by notifications package is {0}, your Player Settings have it set to {1}",
                                                              (int)kMinAndroidSdk, PlayerSettings.Android.minSdkVersion));
            }
#endif
        }
 internal static void ApplySettings(
     AndroidBuildType androidBuildType   = AndroidBuildType.Release,
     AndroidSdkVersions minSdkVersion    = AndroidSdkVersions.AndroidApiLevel18,
     AndroidSdkVersions targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto,
     AndroidPreferredInstallLocation preferredInstallLocation = AndroidPreferredInstallLocation.Auto,
     bool forceInternetPermission = true,
     bool forceSDCardPermission   = true,
     bool androidIsGame           = true
     )
 {
     UnityEditor.PlayerSettings.Android.androidIsGame            = androidIsGame;
     UnityEditor.PlayerSettings.Android.minSdkVersion            = minSdkVersion;
     UnityEditor.PlayerSettings.Android.targetSdkVersion         = targetSdkVersion;
     UnityEditor.PlayerSettings.Android.preferredInstallLocation = preferredInstallLocation;
     UnityEditor.PlayerSettings.Android.forceInternetPermission  = forceInternetPermission;
     UnityEditor.PlayerSettings.Android.forceSDCardPermission    = forceSDCardPermission;
 }
Beispiel #11
0
    /// <summary>
    /// 读取相关参数
    /// </summary>
    private static void Load2Android()
    {
        companyName  = Application.companyName;
        prodectName  = Application.productName;
        qualityLevel = QualitySettings.GetQualityLevel();

        targetPatch = PlayerPrefs.GetString("Editor_targetPatch", "../../" + @"\Android\AESafety\");

        packName = PlayerSettings.GetApplicationIdentifier(buildTargetGroup);

        script = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android);

        targetSdkVersion = PlayerSettings.Android.targetSdkVersion;
        minSdkVersion    = PlayerSettings.Android.minSdkVersion;

        scriptingRuntimeVersion     = PlayerSettings.scriptingRuntimeVersion;
        scriptingBackend            = PlayerSettings.GetScriptingBackend(buildTargetGroup);
        il2CppCompilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
    }
Beispiel #12
0
    static Startup()
    {
#if UNITY_ANDROID
        AndroidSdkVersions minSupportedApiVersion = AndroidSdkVersions.AndroidApiLevel16;
        AndroidSdkVersions apiVersion             = PlayerSettings.Android.minSdkVersion;
        if (apiVersion < minSupportedApiVersion)
        {
            string minApiError = "The application's minimum API version (" + apiVersion + ") is less than the required API version by Megacool (" +
                                 minSupportedApiVersion + ")";

            if (EditorUtility.DisplayDialog("Megacool API", minApiError,
                                            "Change to " + minSupportedApiVersion, "Cancel"))
            {
                PlayerSettings.Android.minSdkVersion = minSupportedApiVersion;
            }
        }
        MegacoolEditor.WarnIfAndroidAndVulkanEnabled();
#endif
    }
        /// <summary>
        /// Overrides the preprocess method to apply AndroidProductInfo to the PlayerSettings.
        /// <summary>
        override public void Preprocess()
        {
            base.Preprocess();

            AndroidProductInfo info;

            info = PlatformUtil.GetSettings <AndroidProductInfo>();

                        #if !SAGO_BUILD_DO_NOT_USE_VERSION_SERVICE
            if (!VersionService.Bump(info))
            {
                throw new System.InvalidOperationException("Could not bump build number.");
            }
                        #endif

            if (info)
            {
                // store the player settings
                this.ProductName       = PlayerSettings.productName;
                this.BuildTargetGroup  = EditorUserBuildSettings.activeBuildTarget.ConvertToGroup();
                this.BundleIdentifier  = PlayerSettings.applicationIdentifier;
                this.BundleVersion     = PlayerSettings.bundleVersion;
                this.BundleVersionCode = PlayerSettings.Android.bundleVersionCode;
                this.SdkVersion        = PlayerSettings.Android.minSdkVersion;

                // copy product info to player settings
                PlayerSettings.productName = info.DisplayName;
                PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, info.Identifier);
                PlayerSettings.bundleVersion             = ProductInfo.CheckVersion(info.Version);
                PlayerSettings.Android.bundleVersionCode = ProductInfo.CheckBuild(info.Build);
                PlayerSettings.Android.minSdkVersion     = (AndroidSdkVersions)info.SdkVersion;
            }

                        #if !UNITY_CLOUD_BUILD && TEAMCITY_BUILD
                                #if SAGO_ANDROID_USE_GRADLE_BUILD_SYSTEM
            EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
                                #else
            EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Internal;
                                #endif
                        #endif
        }
Beispiel #14
0
    static void CheckStaticAndroidIssues()
    {
        AndroidSdkVersions recommendedAndroidSdkVersion = AndroidSdkVersions.AndroidApiLevel19;

        if ((int)PlayerSettings.Android.minSdkVersion < (int)recommendedAndroidSdkVersion &&
            EditorUtility.DisplayDialog("Optimize Android API Level?", "To avoid legacy work-arounds, please require at least API level " + (int)recommendedAndroidSdkVersion, "Use recommended", "Skip"))
        {
            PlayerSettings.Android.minSdkVersion = recommendedAndroidSdkVersion;
        }

        var materials = Resources.FindObjectsOfTypeAll <Material> ();

        for (int i = 0; i < materials.Length; ++i)
        {
            if (materials [i].IsKeywordEnabled("_SPECGLOSSMAP") || materials [i].IsKeywordEnabled("_METALLICGLOSSMAP") &&
                EditorUtility.DisplayDialog("Optimize Specular Material?", "For GPU performance, please don't use specular shader on material " + materials [i].name, "Use recommended", "Skip"))
            {
                materials [i].DisableKeyword("_SPECGLOSSMAP");
                materials [i].DisableKeyword("_METALLICGLOSSMAP");
            }

            if (materials [i].passCount > 1)
            {
                Debug.LogWarning("Please use 2 or fewer passes in material " + materials [i].name);
            }
        }

#if UNITY_5_5_OR_NEWER
        ScriptingImplementation backend = PlayerSettings.GetScriptingBackend(UnityEditor.BuildTargetGroup.Android);
        if (backend != UnityEditor.ScriptingImplementation.IL2CPP &&
            EditorUtility.DisplayDialog("Optimize Scripting Backend?", "For CPU performance, please use IL2CPP.", "Use recommended", "Skip"))
        {
            PlayerSettings.SetScriptingBackend(UnityEditor.BuildTargetGroup.Android, UnityEditor.ScriptingImplementation.IL2CPP);
        }
#else
        ScriptingImplementation backend = (ScriptingImplementation)PlayerSettings.GetPropertyInt("ScriptingBackend", UnityEditor.BuildTargetGroup.Android);
        if (backend != UnityEditor.ScriptingImplementation.IL2CPP &&
            EditorUtility.DisplayDialog("Optimize Scripting Backend?", "For CPU performance, please use IL2CPP.", "Use recommended", "Skip"))
        {
            PlayerSettings.SetPropertyInt("ScriptingBackend", (int)UnityEditor.ScriptingImplementation.IL2CPP, UnityEditor.BuildTargetGroup.Android);
        }
#endif

        var         monoBehaviours = GameObject.FindObjectsOfType <MonoBehaviour> ();
        System.Type effectBaseType = System.Type.GetType("UnityStandardAssets.ImageEffects.PostEffectsBase");
        if (effectBaseType != null)
        {
            for (int i = 0; i < monoBehaviours.Length; ++i)
            {
                if (monoBehaviours [i].GetType().IsSubclassOf(effectBaseType))
                {
                    Debug.LogWarning("Please don't use image effects.");
                }
            }
        }

        var textures = Resources.FindObjectsOfTypeAll <Texture2D> ();

        int maxTextureSize = 1024 * (1 << QualitySettings.masterTextureLimit);
        maxTextureSize = maxTextureSize * maxTextureSize;

        for (int i = 0; i < textures.Length; ++i)
        {
            if (textures [i].filterMode == FilterMode.Trilinear && textures [i].mipmapCount == 1 &&
                EditorUtility.DisplayDialog("Optimize Texture Filtering?", "For GPU performance, please generate mipmaps or disable trilinear filtering for texture " + textures [i].name, "Use recommended", "Skip"))
            {
                textures [i].filterMode = FilterMode.Bilinear;
            }
        }

        var projectors = GameObject.FindObjectsOfType <Projector> ();
        if (projectors.Length > 0 &&
            EditorUtility.DisplayDialog("Optimize Projectors?", "For GPU performance, please don't use projectors.", "Use recommended", "Skip"))
        {
            for (int i = 0; i < projectors.Length; ++i)
            {
                projectors[i].enabled = false;
            }
        }

        if (EditorUserBuildSettings.androidBuildSubtarget != MobileTextureSubtarget.ASTC &&
            EditorUtility.DisplayDialog("Optimize Texture Compression?", "For GPU performance, please use ASTC.", "Use recommended", "Skip"))
        {
            EditorUserBuildSettings.androidBuildSubtarget = MobileTextureSubtarget.ASTC;
        }

        var cameras    = GameObject.FindObjectsOfType <Camera> ();
        int clearCount = 0;
        for (int i = 0; i < cameras.Length; ++i)
        {
            if (cameras [i].clearFlags != CameraClearFlags.Nothing && cameras [i].clearFlags != CameraClearFlags.Depth)
            {
                ++clearCount;
            }
        }

        if (clearCount > 2)
        {
            Debug.LogWarning("Please use 2 or fewer clears.");
        }
    }
    public override void OnInspectorGUI()
    {
        try
        {
            // Might be null when this gui is open and this file is being reimported
            if (target == null)
            {
                Selection.activeObject = null;
                return;
            }

            currentSettings = (UnitySocialSettings)target;

            if (currentSettings != null)
            {
                bool settingsValid = currentSettings.IsValid;

                EditorGUILayout.HelpBox("1) Enter your game credentials", MessageType.None);

                if (!currentSettings.IsValid)
                {
                    EditorGUILayout.HelpBox("Invalid or missing game credentials, Unity Social disabled.", MessageType.Error);
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(labelClientId, GUILayout.Width(108), GUILayout.Height(18));
                currentSettings.clientId = TrimmedText(EditorGUILayout.TextField(currentSettings.clientId));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.HelpBox("2) Enable Unity Social on these platforms", MessageType.None);

                EditorGUILayout.BeginVertical();

                bool validityChanged          = currentSettings.IsValid != settingsValid;
                bool selectedPlatformsChanged = false;

                iosSupportEnabled     = EditorGUILayout.Toggle(labelSupport_iOS, currentSettings.iosSupportEnabled);
                androidSupportEnabled = EditorGUILayout.Toggle(labelSupport_Android, currentSettings.androidSupportEnabled);

                if (iosSupportEnabled != currentSettings.iosSupportEnabled)
                {
                    selectedPlatformsChanged          = true;
                    currentSettings.iosSupportEnabled = iosSupportEnabled;

                    if (iosSupportEnabled)
                    {
                        iOSTargetOSVersion v = PlayerSettings.iOS.targetOSVersion;

                        if (v == iOSTargetOSVersion.iOS_4_0 || v == iOSTargetOSVersion.iOS_4_1 || v == iOSTargetOSVersion.iOS_4_2 ||
                            v == iOSTargetOSVersion.iOS_4_3 || v == iOSTargetOSVersion.iOS_5_0 || v == iOSTargetOSVersion.iOS_5_1 ||
                            v == iOSTargetOSVersion.iOS_6_0 || v == iOSTargetOSVersion.Unknown)
                        {
                            PlayerSettings.iOS.targetOSVersion = iOSTargetOSVersion.iOS_7_0;
                            Debug.Log("Unity Social requires minimum iOS 7.0. Target OS version updated to 7.0");
                        }
                    }

                    EditorUtility.SetDirty(currentSettings);
                }
                else if (androidSupportEnabled != currentSettings.androidSupportEnabled)
                {
                    EnableAndroidSupport(androidSupportEnabled);
                    selectedPlatformsChanged = true;
                    currentSettings.androidSupportEnabled = androidSupportEnabled;

                    if (androidSupportEnabled)
                    {
                        AndroidSdkVersions sdkVer = PlayerSettings.Android.minSdkVersion;

                        if (sdkVer < AndroidSdkVersions.AndroidApiLevel16)
                        {
                            PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel16;
                            Debug.Log("Unity Social requires minimum Android API level 16. API minSdkVersion updated to 16.");
                        }
                    }

                    EditorUtility.SetDirty(currentSettings);
                }

                if (validityChanged || selectedPlatformsChanged)
                {
                    UnitySocialPostprocessor.ValidateState(currentSettings);
                }

                EditorGUILayout.EndVertical();
            }
        }
        catch (Exception e)
        {
            if (e != null)
            {
            }
        }
    }
Beispiel #16
0
    /// <summary>
    /// Android部分对应显示
    /// </summary>
    private void ShowAndroid()
    {
        EditorGUILayout.BeginVertical();

        companyName = EditorGUILayout.TextField("公司名:", companyName);
        prodectName = EditorGUILayout.TextField("项目名:", prodectName);
        packName    = EditorGUILayout.TextField("包名:", packName);

        var _s = Directory.Exists(targetPatch).ToString();


        if (Directory.Exists(targetPatch))
        {
            EditorGUILayout.LabelField("路径是否正确 : " + _s, greenStyleSmile);
        }
        else
        {
            EditorGUILayout.LabelField("路径是否正确 : " + _s, redStyleSmile);
        }


        targetPatch = EditorGUILayout.TextField("项目路径:", targetPatch);

        qualityLevel = EditorGUILayout.IntField("图形质量:" + QualitySettings.names[qualityLevel] + "最大:" + (QualitySettings.names.Length - 1), qualityLevel);
        qualityLevel = qualityLevel <= QualitySettings.names.Length - 1 ? qualityLevel : QualitySettings.names.Length - 1;

        EditorGUILayout.LabelField("Android设置:");

        script                  = EditorGUILayout.TextField("项目注入:", script);
        targetSdkVersion        = (AndroidSdkVersions)EditorGUILayout.EnumPopup("目标SDK:", targetSdkVersion);
        minSdkVersion           = (AndroidSdkVersions)EditorGUILayout.EnumPopup("最小SDK:", minSdkVersion);
        scriptingRuntimeVersion = (ScriptingRuntimeVersion)EditorGUILayout.EnumPopup(".Net环境:", scriptingRuntimeVersion);
        scriptingBackend        = (ScriptingImplementation)EditorGUILayout.EnumPopup("压缩方式:", scriptingBackend);

        if (scriptingBackend == ScriptingImplementation.IL2CPP)
        {
            il2CppCompilerConfiguration = (Il2CppCompilerConfiguration)EditorGUILayout.EnumPopup("打包方式:", il2CppCompilerConfiguration);
        }



        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("读取"))
        {
            Load2Android();
            this.Repaint();
        }

        if (GUILayout.Button("写入"))
        {
            Write2Android();
        }

        if (GUILayout.Button("打包(如有变更先写入)"))
        {
            var file = Build2Android();
            if (file.Length > 0)
            {
                if (EditorUtility.DisplayDialog("PackManager", "导出成功,是否导入Android工程", "Yep", "Closs"))
                {
                    var ass = targetPatch + @"app\src\main\assets\bin";
                    var jl  = targetPatch + @"app\src\main\jniLibs";

                    var assnew = @"ForAndroid\" + prodectName + @"\src\main\assets\bin";
                    var jlnew  = @"ForAndroid\" + prodectName + @"\src\main\jniLibs";

                    try
                    {
                        if (Directory.Exists(ass) && Directory.Exists(jl))
                        {
                            Directory.Delete(ass, true);
                            Directory.Delete(jl, true);
                        }

                        Directory.Move(assnew, ass);
                        Directory.Move(jlnew, jl);



                        Directory.Delete("ForAndroid", true);

                        Assembly   assembly           = Assembly.GetAssembly(typeof(SceneView));
                        Type       logEntries         = assembly.GetType("UnityEditor.LogEntries");
                        MethodInfo clearConsoleMethod = logEntries.GetMethod("Clear");
                        clearConsoleMethod.Invoke(new object(), null);

                        Debug.Log("打包完成!");

                        this.Close();
                    }
                    catch (System.Exception e)
                    {
                        if (EditorUtility.DisplayDialog("PackManager", e.Message, "Closs"))
                        {
                            this.Close();
                        }
                    }
                }
                else
                {
                    this.Close();
                }
            }
        }

        if (GUILayout.Button("关闭"))
        {
            this.Close();
        }

        try
        {
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
        catch (Exception)
        {
            Debug.Log("Why is always consle ?");
        }
    }
        public override void OnInspectorGUI()
        {
            try
            {
                // Might be null when this gui is open and this file is being reimported
                if (target == null)
                {
                    Selection.activeObject = null;
                    return;
                }

                m_CurrentSettings = (UnitySocialSettings)target;

                if (m_CurrentSettings != null)
                {
                    bool settingsValid = m_CurrentSettings.isValid;

                    EditorGUILayout.HelpBox("1) Enter your game credentials", MessageType.None);

                    if (!m_CurrentSettings.isValid)
                    {
                        EditorGUILayout.HelpBox("Invalid or missing game credentials, Unity Social disabled.", MessageType.Error);
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(s_LabelClientId, GUILayout.Width(108), GUILayout.Height(18));
                    string newClientId = TrimmedText(EditorGUILayout.TextField(m_CurrentSettings.clientId));
                    if (m_CurrentSettings.clientId != newClientId)
                    {
                        m_CurrentSettings.clientId = newClientId;
                        GameServicesEditor.BakeGameServicesData();
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.HelpBox("2) Enable Unity Social on these platforms", MessageType.None);

                    EditorGUILayout.BeginVertical();

                    bool validityChanged          = m_CurrentSettings.isValid != settingsValid;
                    bool selectedPlatformsChanged = false;

                    m_IOSSupportEnabled     = EditorGUILayout.Toggle(s_LabelSupport_iOS, m_CurrentSettings.iosSupportEnabled);
                    m_AndroidSupportEnabled = EditorGUILayout.Toggle(s_LabelSupport_Android, m_CurrentSettings.androidSupportEnabled);

                    if (GUILayout.Button("Refresh Baked Game Services Data"))
                    {
                        GameServicesEditor.BakeGameServicesData();
                    }

                    if (m_IOSSupportEnabled != m_CurrentSettings.iosSupportEnabled)
                    {
                        selectedPlatformsChanged            = true;
                        m_CurrentSettings.iosSupportEnabled = m_IOSSupportEnabled;

                        if (m_IOSSupportEnabled)
                        {
                            FixiOSVersion();
                        }

                        GameServicesEditor.BakeGameServicesData();
                        EditorUtility.SetDirty(m_CurrentSettings);
                    }
                    else if (m_AndroidSupportEnabled != m_CurrentSettings.androidSupportEnabled)
                    {
                        EnableAndroidSupport(m_AndroidSupportEnabled);
                        UnitySocialAndroidDependencies.SetAndroidManifestConfig(m_CurrentSettings);
                        selectedPlatformsChanged = true;
                        m_CurrentSettings.androidSupportEnabled = m_AndroidSupportEnabled;

                        GameServicesEditor.BakeGameServicesData();
                        if (m_AndroidSupportEnabled)
                        {
                            AndroidSdkVersions sdkVer = PlayerSettings.Android.minSdkVersion;

                            if (sdkVer < AndroidSdkVersions.AndroidApiLevel16)
                            {
                                PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel16;
                                Debug.Log("Unity Social requires minimum Android API level 16. API minSdkVersion updated to 16.");
                            }
                        }

                        EditorUtility.SetDirty(m_CurrentSettings);
                    }

                    if (m_AndroidSupportEnabled)
                    {
                        AndroidPushNotificationSettings();

                        if (GUILayout.Button("Force Import Android dependencies"))
                        {
                            UnitySocialAndroidDependencies.PlayServicesImport();
                        }
                    }

                    if (validityChanged || selectedPlatformsChanged)
                    {
                        UnitySocialPostprocessor.ValidateState(m_CurrentSettings);
                    }

                    EditorGUILayout.EndVertical();
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #18
0
    static void CheckStaticAndroidIssues()
    {
        if (OVRDeviceSelector.isTargetDeviceQuest && PlayerSettings.Android.targetArchitectures != AndroidArchitecture.ARM64)
        {
            // Quest store is only accepting 64-bit apps as of November 25th 2019
            AddFix("Set Target Architecture to ARM64", "32-bit Quest apps are no longer being accepted on the Oculus Store.",
                   delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
            }, null, false, "Fix");
        }

        // Check that the minSDKVersion meets requirement, 21 for Gear and Go, 23 for Quest
        AndroidSdkVersions recommendedAndroidMinSdkVersion = AndroidSdkVersions.AndroidApiLevel21;

        if (OVRDeviceSelector.isTargetDeviceQuest)
        {
            recommendedAndroidMinSdkVersion = AndroidSdkVersions.AndroidApiLevel23;
        }
        if ((int)PlayerSettings.Android.minSdkVersion < (int)recommendedAndroidMinSdkVersion)
        {
            AddFix("Set Min Android API Level", "Please require at least API level " + (int)recommendedAndroidMinSdkVersion, delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.Android.minSdkVersion = recommendedAndroidMinSdkVersion;
            }, null, false, "Fix");
        }

        // Check that compileSDKVersion meets minimal version 26 as required for Quest's headtracking feature
        // Unity Sets compileSDKVersion in Gradle as the value used in targetSdkVersion
        AndroidSdkVersions requiredAndroidTargetSdkVersion = AndroidSdkVersions.AndroidApiLevel26;

        if (OVRDeviceSelector.isTargetDeviceQuest &&
            (int)PlayerSettings.Android.targetSdkVersion < (int)requiredAndroidTargetSdkVersion)
        {
            AddFix("Set Android Target SDK Level", "Oculus Quest apps require at least target API level " +
                   (int)requiredAndroidTargetSdkVersion, delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.Android.targetSdkVersion = requiredAndroidTargetSdkVersion;
            }, null, false, "Fix");
        }

        if (!PlayerSettings.gpuSkinning)
        {
            AddFix("Optimize GPU Skinning", "If you are CPU-bound, consider using GPU skinning.",
                   delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.gpuSkinning = true;
            }, null, false, "Fix");
        }


        if (RenderSettings.skybox)
        {
            AddFix("Optimize Clearing", "For GPU performance, please don't use Unity's built-in Skybox.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                RenderSettings.skybox = null;
            }, null, false, "Clear Skybox");
        }

        var materials = Resources.FindObjectsOfTypeAll <Material>();

        for (int i = 0; i < materials.Length; ++i)
        {
            if (materials[i].IsKeywordEnabled("_SPECGLOSSMAP") || materials[i].IsKeywordEnabled("_METALLICGLOSSMAP"))
            {
                AddFix("Optimize Specular Material", "For GPU performance, please don't use specular shader on materials.", delegate(UnityEngine.Object obj, bool last, int selected)
                {
                    Material thisMaterial = (Material)obj;
                    thisMaterial.DisableKeyword("_SPECGLOSSMAP");
                    thisMaterial.DisableKeyword("_METALLICGLOSSMAP");
                }, materials[i], false, "Fix");
            }

            if (materials[i].passCount > 2)
            {
                AddFix("Material Passes", "Please use 2 or fewer passes in materials.", null, materials[i], false);
            }
        }

        ScriptingImplementation backend = PlayerSettings.GetScriptingBackend(UnityEditor.BuildTargetGroup.Android);

        if (backend != UnityEditor.ScriptingImplementation.IL2CPP)
        {
            AddFix("Optimize Scripting Backend", "For CPU performance, please use IL2CPP.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.SetScriptingBackend(UnityEditor.BuildTargetGroup.Android, UnityEditor.ScriptingImplementation.IL2CPP);
            }, null, false, "Fix");
        }

        var monoBehaviours = GameObject.FindObjectsOfType <MonoBehaviour>();

        System.Type effectBaseType = System.Type.GetType("UnityStandardAssets.ImageEffects.PostEffectsBase");
        if (effectBaseType != null)
        {
            for (int i = 0; i < monoBehaviours.Length; ++i)
            {
                if (monoBehaviours[i].GetType().IsSubclassOf(effectBaseType))
                {
                    AddFix("Image Effects", "Please don't use image effects.", null, monoBehaviours[i], false);
                }
            }
        }

        var textures = Resources.FindObjectsOfTypeAll <Texture2D>();

        int maxTextureSize = 1024 * (1 << QualitySettings.masterTextureLimit);

        maxTextureSize = maxTextureSize * maxTextureSize;

        for (int i = 0; i < textures.Length; ++i)
        {
            if (textures[i].filterMode == FilterMode.Trilinear && textures[i].mipmapCount == 1)
            {
                AddFix("Optimize Texture Filtering", "For GPU performance, please generate mipmaps or disable trilinear filtering for textures.", delegate(UnityEngine.Object obj, bool last, int selected)
                {
                    Texture2D thisTexture = (Texture2D)obj;
                    if (selected == 0)
                    {
                        thisTexture.filterMode = FilterMode.Bilinear;
                    }
                    else
                    {
                        SetTextureUseMips(thisTexture, true, last);
                    }
                }, textures[i], false, "Switch to Bilinear", "Generate Mipmaps");
            }
        }

        var projectors = GameObject.FindObjectsOfType <Projector>();

        if (projectors.Length > 0)
        {
            AddFix("Optimize Projectors", "For GPU performance, please don't use projectors.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                Projector[] thisProjectors = GameObject.FindObjectsOfType <Projector>();
                for (int i = 0; i < thisProjectors.Length; ++i)
                {
                    thisProjectors[i].enabled = false;
                }
            }, null, false, "Disable Projectors");
        }

        if (EditorUserBuildSettings.androidBuildSubtarget != MobileTextureSubtarget.ASTC)
        {
            AddFix("Optimize Texture Compression", "For GPU performance, please use ASTC.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                EditorUserBuildSettings.androidBuildSubtarget = MobileTextureSubtarget.ASTC;
            }, null, false, "Fix");
        }

        var cameras    = GameObject.FindObjectsOfType <Camera>();
        int clearCount = 0;

        for (int i = 0; i < cameras.Length; ++i)
        {
            if (cameras[i].clearFlags != CameraClearFlags.Nothing && cameras[i].clearFlags != CameraClearFlags.Depth)
            {
                ++clearCount;
            }
        }

        if (clearCount > 2)
        {
            AddFix("Camera Clears", "Please use 2 or fewer clears.", null, null, false);
        }

        for (int i = 0; i < cameras.Length; ++i)
        {
            if (cameras[i].forceIntoRenderTexture)
            {
                AddFix("Optimize Mobile Rendering", "For GPU performance, please don't enable forceIntoRenderTexture on your camera, this might be a flag pollution created by post process stack you used before, \nif your post process had already been turned off, we strongly encourage you to disable forceIntoRenderTexture. If you still want to use post process for some reasons, \nyou can leave this one on, but be warned, enabling this flag will introduce huge GPU performance cost. To view your flag status, please turn on you inspector's debug mode",
                       delegate(UnityEngine.Object obj, bool last, int selected)
                {
                    Camera thisCamera = (Camera)obj;
                    thisCamera.forceIntoRenderTexture = false;
                }, cameras[i], false, "Disable forceIntoRenderTexture");
            }
        }
    }
Beispiel #19
0
    static void CheckStaticAndroidIssues()
    {
        AndroidSdkVersions recommendedAndroidSdkVersion = AndroidSdkVersions.AndroidApiLevel19;

        if ((int)PlayerSettings.Android.minSdkVersion < (int)recommendedAndroidSdkVersion)
        {
            AddFix("Optimize Android API Level", "To avoid legacy work-arounds, please require at least API level " + (int)recommendedAndroidSdkVersion, delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.Android.minSdkVersion = recommendedAndroidSdkVersion;
            }, null, "Fix");
        }

        if (RenderSettings.skybox)
        {
            AddFix("Optimize Clearing", "For GPU performance, please don't use Unity's built-in Skybox.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                RenderSettings.skybox = null;
            }, null, "Clear Skybox");
        }

        var materials = Resources.FindObjectsOfTypeAll <Material> ();

        for (int i = 0; i < materials.Length; ++i)
        {
            if (materials [i].IsKeywordEnabled("_SPECGLOSSMAP") || materials [i].IsKeywordEnabled("_METALLICGLOSSMAP"))
            {
                AddFix("Optimize Specular Material", "For GPU performance, please don't use specular shader on materials.", delegate(UnityEngine.Object obj, bool last, int selected)
                {
                    Material thisMaterial = (Material)obj;
                    thisMaterial.DisableKeyword("_SPECGLOSSMAP");
                    thisMaterial.DisableKeyword("_METALLICGLOSSMAP");
                }, materials[i], "Fix");
            }

            if (materials [i].passCount > 1)
            {
                AddFix("Material Passes", "Please use 2 or fewer passes in materials.", null, materials[i]);
            }
        }

#if UNITY_5_5_OR_NEWER
        ScriptingImplementation backend = PlayerSettings.GetScriptingBackend(UnityEditor.BuildTargetGroup.Android);
        if (backend != UnityEditor.ScriptingImplementation.IL2CPP)
        {
            AddFix("Optimize Scripting Backend", "For CPU performance, please use IL2CPP.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.SetScriptingBackend(UnityEditor.BuildTargetGroup.Android, UnityEditor.ScriptingImplementation.IL2CPP);
            }, null, "Fix");
        }
#else
        ScriptingImplementation backend = (ScriptingImplementation)PlayerSettings.GetPropertyInt("ScriptingBackend", UnityEditor.BuildTargetGroup.Android);
        if (backend != UnityEditor.ScriptingImplementation.IL2CPP)
        {
            AddFix("Optimize Scripting Backend", "For CPU performance, please use IL2CPP.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                PlayerSettings.SetPropertyInt("ScriptingBackend", (int)UnityEditor.ScriptingImplementation.IL2CPP, UnityEditor.BuildTargetGroup.Android);
            }, null, "Fix");
        }
#endif

        var         monoBehaviours = GameObject.FindObjectsOfType <MonoBehaviour> ();
        System.Type effectBaseType = System.Type.GetType("UnityStandardAssets.ImageEffects.PostEffectsBase");
        if (effectBaseType != null)
        {
            for (int i = 0; i < monoBehaviours.Length; ++i)
            {
                if (monoBehaviours [i].GetType().IsSubclassOf(effectBaseType))
                {
                    AddFix("Image Effects", "Please don't use image effects.", null, monoBehaviours[i]);
                }
            }
        }

        var textures = Resources.FindObjectsOfTypeAll <Texture2D> ();

        int maxTextureSize = 1024 * (1 << QualitySettings.masterTextureLimit);
        maxTextureSize = maxTextureSize * maxTextureSize;

        for (int i = 0; i < textures.Length; ++i)
        {
            if (textures [i].filterMode == FilterMode.Trilinear && textures [i].mipmapCount == 1)
            {
                AddFix("Optimize Texture Filtering", "For GPU performance, please generate mipmaps or disable trilinear filtering for textures.", delegate(UnityEngine.Object obj, bool last, int selected)
                {
                    Texture2D thisTexture = (Texture2D)obj;
                    if (selected == 0)
                    {
                        thisTexture.filterMode = FilterMode.Bilinear;
                    }
                    else
                    {
                        SetTextureUseMips(thisTexture, true, last);
                    }
                }, textures[i], "Switch to Bilinear", "Generate Mipmaps");
            }
        }

        var projectors = GameObject.FindObjectsOfType <Projector> ();
        if (projectors.Length > 0)
        {
            AddFix("Optimize Projectors", "For GPU performance, please don't use projectors.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                Projector[] thisProjectors = GameObject.FindObjectsOfType <Projector> ();
                for (int i = 0; i < thisProjectors.Length; ++i)
                {
                    thisProjectors[i].enabled = false;
                }
            }, null, "Disable Projectors");
        }

        if (EditorUserBuildSettings.androidBuildSubtarget != MobileTextureSubtarget.ASTC)
        {
            AddFix("Optimize Texture Compression", "For GPU performance, please use ASTC.", delegate(UnityEngine.Object obj, bool last, int selected)
            {
                EditorUserBuildSettings.androidBuildSubtarget = MobileTextureSubtarget.ASTC;
            }, null, "Fix");
        }

        var cameras    = GameObject.FindObjectsOfType <Camera> ();
        int clearCount = 0;
        for (int i = 0; i < cameras.Length; ++i)
        {
            if (cameras [i].clearFlags != CameraClearFlags.Nothing && cameras [i].clearFlags != CameraClearFlags.Depth)
            {
                ++clearCount;
            }
        }

        if (clearCount > 2)
        {
            AddFix("Camera Clears", "Please use 2 or fewer clears.", null, null);
        }
    }
Beispiel #20
0
 public void Reload(AnyDictionary dict)
 {
     min    = ConvertVersion(dict.GetValue <int>("min"));
     target = ConvertVersion(dict.GetValue <int>("target"));
 }