예제 #1
0
    static void Update()
    {
        bool show =
            PlayerSettings.renderingPath != recommended_RenderPath ||
            PlayerSettings.colorSpace != recommended_ColorSpace ||
            PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen ||
            PlayerSettings.apiCompatibilityLevel != recommended_APICompatibilityLevel ||
            PlayerSettings.companyName != recommended_CompanyName ||
            PlayerSettings.productName != recommended_ProductName ||
            PlayerSettings.resolutionDialogBanner == null ||
            PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown)[0] == null ||
            forceShow;

        if (show)
        {
            Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);

            window          = GetWindow <TournamentSettings>(true, "Tournament Settings", true);
            window.position = new Rect
                              (
                (Screen.currentResolution.width / 2) - (windowSize.x / 2),
                (Screen.currentResolution.height / 2) - (windowSize.y / 2),
                windowSize.x,
                windowSize.y
                              );

            window.minSize = new Vector2(windowSize.x, windowSize.y);
            window.maxSize = new Vector2(windowSize.x, windowSize.y);
        }

        EditorApplication.update -= Update;
    }
예제 #2
0
        //Get The closest match to create the icon
        public static void CreateIconFromDefault(string iconsFolder, int size)
        {
            Texture2D[] icons = PlayerSettings.GetIconsForTargetGroup(0);
            if (icons == null || icons.Length == 0 || icons [0] == null)
            {
                Texture2D logo = AssetDatabase.LoadAssetAtPath <Texture2D> ("Assets/ChromeAppBuilder/Editor/Resources/logo.png");
                if (logo == null)
                {
                    return;
                }
                icons     = new Texture2D[1];
                icons [0] = logo;
            }
            int MinDiff = icons [0].width - size;
            int index   = 0;

            for (int i = 1; i < icons.Length; i++)
            {
                int diff = icons [i].width - size;
                if (diff < MinDiff && diff > 0)
                {
                    MinDiff = diff;
                    index   = i;
                }
            }
            byte[] buffer = LoadTexture(icons [index], size);
            File.WriteAllBytes(Path.Combine(iconsFolder, "icon" + size.ToString() + ".png"), buffer);
        }
예제 #3
0
            private static Texture2D LoadIcon(Func <Texture2D> downloadIcon)
            {
                Texture2D[] textures;
                Texture2D   texture = null;

                if ((textures = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Android)) != null && textures[0] != null)
                {
                    texture = textures[0];
                }

#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
                var buildTargetGroup = BuildTargetGroup.iPhone;
#else
                var buildTargetGroup = BuildTargetGroup.iOS;
#endif

                if ((textures = PlayerSettings.GetIconsForTargetGroup(buildTargetGroup)) != null && textures[0] != null)
                {
                    texture = textures[0];
                }

                if (texture == null)
                {
                    texture = downloadIcon();
                }

                return(texture ?? PlaceHolderImage);
            }
예제 #4
0
        public void Save()
        {
            SetVersion(versionMajor, versionMinor);
            if (PlayerSettings.bundleVersion != version)
            {
                PlayerSettings.bundleVersion = version;
            }

            if (PlayerSettings.productName != productName)
            {
                PlayerSettings.productName = productName;
            }

            if (PlayerSettings.companyName != companyName)
            {
                PlayerSettings.companyName = companyName;
            }

            SetBundleIdentifier();
            if (PlayerSettings.applicationIdentifier != bundleIdentifier)
            {
                PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Standalone, bundleIdentifier);
            }

            Texture2D[] textures = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown, IconKind.Any);
            if (textures.Length == 0 || (textures.Length > 0 && textures[0] != icon))
            {
                PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Unknown, new Texture2D[] { icon }, IconKind.Any);
            }
        }
예제 #5
0
        private void DrawIcon()
        {
            var       totalIcons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);
            Texture2D icon       = totalIcons.FirstOrDefault();

            EditorGUI.BeginChangeCheck();

            var newIcon = EditorGUIExtensions.TextureField("Default Icon", icon);

            if (EditorGUI.EndChangeCheck())
            {
                if (totalIcons.Length <= 0)
                {
                    totalIcons = new Texture2D[] { newIcon };
                }
                else
                {
                    totalIcons[0] = newIcon;
                }

                PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Unknown, totalIcons);
            }

            if (_settings.SelectedPreferences.icon.Required && newIcon == null)
            {
                EditorGUILayout.HelpBox("App has no icon.", MessageType.Warning);
            }
        }
        protected void _DoPreprocessBuild(BuildTarget target, string path)
        {
            BuildTargetGroup buildTargetGroup;

            if (target == BuildTarget.Android)
            {
                buildTargetGroup = BuildTargetGroup.Android;
            }
            else if (target == BuildTarget.iOS)
            {
                buildTargetGroup = BuildTargetGroup.iOS;
            }
            else
            {
                return;
            }

            EditorBuildSettingsScene enabledBuildScene = null;
            int enabledSceneCount = 0;

            foreach (var buildScene in EditorBuildSettings.scenes)
            {
                if (!buildScene.enabled)
                {
                    continue;
                }

                enabledBuildScene = buildScene;
                enabledSceneCount++;
            }

            if (enabledSceneCount != 1)
            {
                return;
            }

            foreach (var exampleScene in m_ExampleScenes)
            {
                if (enabledBuildScene.guid.ToString() == exampleScene.SceneGuid)
                {
                    PlayerSettings.SetApplicationIdentifier(buildTargetGroup, exampleScene.PackageName);
                    PlayerSettings.productName = exampleScene.ProductName;
                    var applicationIcon = AssetDatabase.LoadAssetAtPath <Texture2D>(
                        AssetDatabase.GUIDToAssetPath(exampleScene.IconGuid));

                    var icons = PlayerSettings.GetIconsForTargetGroup(buildTargetGroup, IconKind.Application);
                    for (int i = 0; i < icons.Length; i++)
                    {
                        icons[i] = applicationIcon;
                    }

                    PlayerSettings.SetIconsForTargetGroup(buildTargetGroup, icons, IconKind.Application);
                    break;
                }
            }
        }
    /// <summary>
    /// Loads current player settings.
    /// </summary>
    public void LoadSettings()
    {
        companyName.Value         = PlayerSettings.companyName;
        companyName.UseExpression = false;

        productName.Value         = PlayerSettings.productName;
        productName.UseExpression = false;

        defaultIcon.Value         = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown)[0];
        defaultIcon.UseExpression = false;
    }
예제 #8
0
    /// <summary>
    /// Builds a single APK and places it in the build folder.
    /// </summary>
    /// <param name="settings">Description of the APK to build.</param>
    public static void BuildAPK(APKSettings settings)
    {
        // Don't make any permanent changes to the player settings!
        Texture2D[] oldIcons            = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Android);
        string      oldKeystoreName     = PlayerSettings.Android.keystoreName;
        string      oldkeyaliasName     = PlayerSettings.Android.keyaliasName;
        string      oldKeystorePass     = PlayerSettings.Android.keystorePass;
        string      oldKeyaliasPass     = PlayerSettings.Android.keyaliasPass;
        string      oldProductName      = PlayerSettings.productName;
        string      oldBundleIdentifier = PlayerSettings.bundleIdentifier;

        // make sure the product folder exists
        System.IO.Directory.CreateDirectory(BUILD_DIRECTORY_W_SLASH);

        // set icons (Android currently supports 6 sizes)
        Texture2D icon = (Texture2D)AssetDatabase.LoadMainAssetAtPath(ASSET_DIRECTORY_W_SLASH + settings.Icon);

        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android,
                                              new Texture2D[] { icon, icon, icon, icon, icon, icon });

        string keystoreDir = FindKeystoreDirectory();

        if (keystoreDir != null)
        {
            string keystorePass = ReadKeystorePassword(keystoreDir + "/trailmix-release-key-password.txt");

            PlayerSettings.Android.keystoreName = keystoreDir + "/trailmix-release-key.keystore";
            PlayerSettings.Android.keyaliasName = "alias_name";
            PlayerSettings.Android.keystorePass = PlayerSettings.Android.keyaliasPass = keystorePass;
        }

        // set name and ids
        PlayerSettings.productName      = settings.ProjectName;
        PlayerSettings.bundleIdentifier = settings.BundleIdentifier;

        // and finally... build it!
        string[] scenesUnityPath = new string[settings.Scenes.Length];
        for (int it = 0; it != settings.Scenes.Length; ++it)
        {
            scenesUnityPath[it] = ASSET_DIRECTORY_W_SLASH + settings.Scenes[it];
        }
        BuildPipeline.BuildPlayer(scenesUnityPath, BUILD_DIRECTORY_W_SLASH + settings.ProjectName + ".apk",
                                  BuildTarget.Android, BuildOptions.None);

        // Restore player settings
        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, oldIcons);
        PlayerSettings.Android.keystoreName = oldKeystoreName;
        PlayerSettings.Android.keyaliasName = oldkeyaliasName;
        PlayerSettings.Android.keystorePass = oldKeystorePass;
        PlayerSettings.Android.keyaliasPass = oldKeyaliasPass;
        PlayerSettings.productName          = oldProductName;
        PlayerSettings.bundleIdentifier     = oldBundleIdentifier;
    }
예제 #9
0
        void IconSectionGUI()
        {
            if (BeginSettingsBox(3, new GUIContent("Icon")))
            {
                GUI.changed = false;
                BuildSettings.Get.overrideIcons = GUILayout.Toggle(BuildSettings.Get.overrideIcons, "Override Icons", new GUILayoutOption[0]);
                GUI.enabled = BuildSettings.Get.overrideIcons;
                for (int i = 0; i < Icons.iconSizes.Length; i++)
                {
                    int    num  = Mathf.Min(96, Icons.iconSizes[i]);
                    Rect   rect = GUILayoutUtility.GetRect(64f, (float)(Mathf.Max(64, num) + 6));
                    float  num2 = Mathf.Min(rect.width, EditorGUIUtility.labelWidth + 4f + 64f + 6f + 96f);
                    string text = Icons.iconSizes[i] + "x" + Icons.iconSizes[i];
                    GUI.Label(new Rect(rect.x, rect.y, num2 - 96f - 64f - 12f, 20f), text);

                    Texture2D iconForPlatformAtSize = null;

                    if (BuildSettings.Get.overrideIcons)
                    {
                        BuildSettings.Get.icons [i] = (Texture2D)EditorGUI.ObjectField(new Rect(rect.x + num2 - 96f - 64f - 6f, rect.y, 64f, 64f), BuildSettings.Get.icons [i], typeof(Texture2D), false);
                        iconForPlatformAtSize       = Icons.GetBestFitIcon(Icons.iconSizes [i]);
                    }
                    else
                    {
                        Texture2D[] array = PlayerSettings.GetIconsForTargetGroup(0);
                        if (array.Length > 0)
                        {
                            iconForPlatformAtSize = array [0];
                        }
                    }

                    Rect position = new Rect(rect.x + num2 - 96f, rect.y, (float)num, (float)num);

                    if (iconForPlatformAtSize != null)
                    {
                        GUI.DrawTexture(position, iconForPlatformAtSize);
                    }
                    else
                    {
                        GUI.Box(position, string.Empty);
                    }
                }
                GUI.enabled = true;
            }
            EndSettingsBox();
        }
예제 #10
0
        internal static List <Texture> GetTargetGroupAssetDependencies(BuildTargetGroup targetGroup)
        {
            List <Texture> buildTargetAssetDependencies = new List <Texture>();

            //Run through icons, splashscreens etc and include them as being used
            Texture2D[]      targetGroupIcons           = PlayerSettings.GetIconsForTargetGroup(targetGroup);
            List <Texture2D> additionalTargetGroupIcons = getAdditionalTargetAssets(targetGroup);

            Texture2D[] unknownTargetGroupIcons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);

            PlayerSettings.SplashScreenLogo[] splashLogos = PlayerSettings.SplashScreen.logos;

            //Loop default targetgroup icons
            for (int i = 0; i < unknownTargetGroupIcons.Length; i++)
            {
                addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, unknownTargetGroupIcons[i]);
            }
            //Loop targetgroup icons
            for (int i = 0; i < targetGroupIcons.Length; i++)
            {
                addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, targetGroupIcons[i]);
            }
            //Loop additional targetgroup icons
            if (additionalTargetGroupIcons != null)
            {
                for (int i = 0; i < additionalTargetGroupIcons.Count; i++)
                {
                    addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, additionalTargetGroupIcons[i]);
                }
            }
            //Loop splash
            for (int i = 0; i < splashLogos.Length; i++)
            {
                addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, splashLogos[i].logo);
            }

            //Get all the custom playersetting textures
            addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, PlayerSettings.defaultCursor);
            addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, PlayerSettings.virtualRealitySplashScreen);
            addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, PlayerSettings.SplashScreen.background);
            addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, PlayerSettings.SplashScreen.backgroundPortrait);
#if !UNITY_2019_1_OR_NEWER
            addTextureToPlayerSettingsList(ref buildTargetAssetDependencies, PlayerSettings.resolutionDialogBanner);
#endif
            return(buildTargetAssetDependencies);
        }
예제 #11
0
        private void FindAllIcons()
        {
            _iconPaths = new List <string>();

            var icons        = new List <Texture2D>();
            var targetGroups = Enum.GetValues(typeof(BuildTargetGroup));

            foreach (var targetGroup in targetGroups)
            {
                icons.AddRange(PlayerSettings.GetIconsForTargetGroup((BuildTargetGroup)targetGroup));
            }

            foreach (var icon in icons)
            {
                _iconPaths.Add(AssetDatabase.GetAssetPath(icon));
            }
        }
예제 #12
0
        public void ConfigTargetGroup(BuildTargetGroup buildTargetGroup)
        {
            if (!string.IsNullOrEmpty(companyName))
            {
                PlayerSettings.companyName = companyName;
            }
            if (!string.IsNullOrEmpty(productName))
            {
                PlayerSettings.productName = productName;
            }
            if (!string.IsNullOrEmpty(bundleVersion))
            {
                PlayerSettings.bundleVersion = bundleVersion;
            }

            if (icon != null)
            {
                Texture2D[] icons = PlayerSettings.GetIconsForTargetGroup(buildTargetGroup, IconKind.Any);
                for (int i = 0; i < icons.Length; i++)
                {
                    icons[i] = icon;
                }
                PlayerSettings.SetIconsForTargetGroup(buildTargetGroup, icons, IconKind.Any);
            }

            if (!string.IsNullOrEmpty(bundleIdentifier))
            {
                PlayerSettings.SetApplicationIdentifier(buildTargetGroup, bundleIdentifier);
            }

            switch (buildTargetGroup)
            {
            case BuildTargetGroup.Standalone:
                PlayerSettings.macOS.buildNumber = buildNumber.ToString();
                break;

            case BuildTargetGroup.iOS:
                PlayerSettings.iOS.buildNumber = buildNumber.ToString();
                break;

            case BuildTargetGroup.Android:
                PlayerSettings.Android.bundleVersionCode = buildNumber;
                break;
            }
        }
예제 #13
0
    /// <summary>
    /// 取得PlayerSetting上的Icon圖片
    /// </summary>
    public static void GetIconsGroup(BuildTargetGroup iTarget, ref Texture2D[] iIcons, ref string[] iIconNames)
    {
        iIcons = PlayerSettings.GetIconsForTargetGroup(iTarget);
        string[] aDefNames = new string[iIcons.Length];
        for (int i = 0; i < iIcons.Length; i++)
        {
            if (iIcons[i] != null)
            {
                aDefNames[i] = iIcons[i].name;
            }
            else
            {
                aDefNames[i] = string.Empty;
            }
        }

        iIconNames = aDefNames;
    }
    void Start()
    {
#if UNITY_EDITOR
        Texture2D[] icons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);
        if (icons[0] != null)
        {
            foreach (Image image in AppIcons)
            {
                image.sprite = Sprite.Create(icons[0], new Rect(0.0f, 0.0f, icons[0].width, icons[0].height), new Vector2(0.5f, 0.5f));
            }
        }

        foreach (Text name in AppNames)
        {
            name.text = PlayerSettings.productName;
        }
#endif
    }
예제 #15
0
    public static void BuildWindowsStandalone()
    {
        string[] levels   = { "Assets/Scenes/Main.unity" };
        string   filename = string.Empty;


        filename = "Assets/Resources/icons/msp.png";
        Texture2D[] icon = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Standalone);//;new Texture2D[7];
        Debug.LogError("icons size " + icon.Length);
        for (int i = 0; i < icon.Length; i++)
        {
            icon[i] = (Texture2D)AssetDatabase.LoadAssetAtPath(filename, typeof(Texture2D));
        }
        Debug.LogError("replace file from " + filename + " to all icons");
        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Standalone, icon);
        FileUtil.ReplaceFile(filename, "Assets/Annex/Textures/UI/defaulticon.png");  //用这种方式把defaulticon替换掉
        Debug.LogError("replace file from " + filename + " to Assets/Annex/Textures/UI/defaulticon.png");
        PlayerSettings.productName = "MySwingPro";
        BuildPipeline.BuildPlayer(levels, "MySwingPro.exe", BuildTarget.StandaloneWindows, BuildOptions.None);
    }
예제 #16
0
    static void BuildForStandaloneWindows()
    {
        string[] levels = { "Assets/Scenes/1.unity" };
        string   path   = GetExportPath(BuildTarget.StandaloneWindows);

        PlayerSettings.defaultIsFullScreen     = false;
        PlayerSettings.companyName             = companyName;
        PlayerSettings.productName             = productName;
        PlayerSettings.resizableWindow         = false;
        PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;

        var tx = Resources.Load <Texture2D>("icon");

        Texture2D[] txs   = { tx, tx, tx, tx, tx, tx, tx, };
        var         lengt = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Standalone);

        if (txs != null)
        {
            PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Standalone, txs);
        }
        var st = BuildPipeline.BuildPlayer(levels, path, BuildTarget.StandaloneWindows, BuildOptions.None);
    }
예제 #17
0
        private void Load()
        {
            string version = PlayerSettings.bundleVersion;
            int    index   = version.IndexOf('.');

            int versionMajor;
            int versionMinor;

            try
            {
                if (index > 0)
                {
                    versionMajor = int.Parse(version.Substring(0, index));
                    versionMinor = int.Parse(version.Substring(index + 1));
                }
                else
                {
                    versionMajor = int.Parse(version);
                    versionMinor = 0;
                }
            }
            catch
            {
                Debug.LogError(string.Concat("[Builder]: Error getting current version, default to 0."));
                versionMajor = 0;
                versionMinor = 0;
            }

            SetVersion(versionMajor, versionMinor);
            productName      = PlayerSettings.productName;
            companyName      = PlayerSettings.companyName;
            bundleIdentifier = PlayerSettings.applicationIdentifier;

            Texture2D[] textures = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown, IconKind.Any);
            if (textures.Length > 0)
            {
                icon = textures[0];
            }
        }
예제 #18
0
        public static void UpdateUnusedForProjectSettings()
        {
            HashSet <string> unusedAssetsSet = new HashSet <string>();
            var textures = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);

            foreach (var tex in textures)
            {
                var path = AssetDatabase.GetAssetPath(tex);
                if (!string.IsNullOrEmpty(path))
                {
                    unusedAssetsSet.Add(path);
                }
            }

#if UNITY_5_5_OR_NEWER
            if (PlayerSettings.defaultCursor != null)
            {
                unusedAssetsSet.Add(AssetDatabase.GetAssetPath(PlayerSettings.defaultCursor));
            }
#endif

            UpdateUnusedStatusInternal(unusedAssetsSet);
        }
예제 #19
0
    void OnEnable()
    {
        this.icons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);

        this.bundleVersion          = PlayerSettings.bundleVersion;
        this.bundleVersionCode      = PlayerSettings.Android.bundleVersionCode;
        this.scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android);

        this.defSym_DYGAME_DEBUGMODE = this.scriptingDefineSymbols.IndexOf(DEFSYM_DYGAME_DEBUGMODE) >= 0;
        this.defSym_ZhiweiDebug      = this.scriptingDefineSymbols.IndexOf(DEFSYM_ZHIWEIDEBUG) >= 0;
        this.defSym_LOBBY_2_5        = this.scriptingDefineSymbols.IndexOf(DEFSYM_LOBBY_2_5) >= 0;
        this.defSym_LOBBY_2_5_MOON   = this.scriptingDefineSymbols.IndexOf(DEFSYM_LOBBY_2_5_MOON) >= 0;

        this.mObj = new SerializedObject(this);

        this.AddProperty("bundleVersion");
        this.AddProperty("bundleVersionCode");
        this.AddProperty("developmentBuild");
        this.AddProperty("defSym_DYGAME_DEBUGMODE");
        this.AddProperty("defSym_ZhiweiDebug");
        this.AddProperty("defSym_LOBBY_2_5");
        this.AddProperty("defSym_LOBBY_2_5_MOON");
        this.AddProperty("icons");
    }
예제 #20
0
        public override void OnInspectorGUI()
        {
            base.DrawDefaultInspector();

            //GUILayout.BeginHorizontal();

            if (GUILayout.Button("Fill from Player Settings"))
            {
                BuildIcons.Icons = PlayerSettings.GetIconsForTargetGroup(BuildIcons.TargetGroup, BuildIcons.IconKind);
                EditorUtility.SetDirty(BuildIcons);
            }

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

            if (GUILayout.Button("Apply To Player Settings"))
            {
                BuildIcons.ApplyToPlayerSettings();
            }

            //GUILayout.EndHorizontal();
        }
예제 #21
0
        protected void DoPreprocessBuild(BuildTarget target, string path)
        {
            BuildTargetGroup buildTargetGroup;

            if (target == BuildTarget.Android)
            {
                buildTargetGroup = BuildTargetGroup.Android;
            }
            else if (target == BuildTarget.iOS)
            {
                buildTargetGroup = BuildTargetGroup.iOS;
            }
            else
            {
                return;
            }

            EditorBuildSettingsScene enabledBuildScene = null;
            int enabledSceneCount = 0;

            foreach (var buildScene in EditorBuildSettings.scenes)
            {
                if (!buildScene.enabled)
                {
                    continue;
                }

                enabledBuildScene = buildScene;
                enabledSceneCount++;
            }

            if (enabledSceneCount != 1)
            {
                return;
            }

            List <Texture2D> exampleSceneIcons   = new List <Texture2D>();
            List <string>    exampleProductNames = new List <string>();

            foreach (var exampleScene in _exampleScenes)
            {
                exampleSceneIcons.Add(AssetDatabase.LoadAssetAtPath <Texture2D>(
                                          AssetDatabase.GUIDToAssetPath(exampleScene.IconGuid)));
                exampleProductNames.Add(exampleScene.ProductName);
            }

            string[] projectFolders     = Application.dataPath.Split('/');
            string   defaultProductName = projectFolders[projectFolders.Length - 2];

            if (PlayerSettings.productName != defaultProductName &&
                !exampleProductNames.Contains(PlayerSettings.productName))
            {
                return;
            }

            Texture2D[] applicationIcons =
                PlayerSettings.GetIconsForTargetGroup(buildTargetGroup, IconKind.Application);

            for (int i = 0; i < applicationIcons.Length; i++)
            {
                if (applicationIcons[i] != null && !exampleSceneIcons.Contains(applicationIcons[i]))
                {
                    return;
                }
            }

            foreach (var exampleScene in _exampleScenes)
            {
                if (enabledBuildScene.guid.ToString() == exampleScene.SceneGuid)
                {
                    PlayerSettings.productName = exampleScene.ProductName;

                    Texture2D exampleIcon = AssetDatabase.LoadAssetAtPath <Texture2D>(
                        AssetDatabase.GUIDToAssetPath(exampleScene.IconGuid));

                    for (int i = 0; i < applicationIcons.Length; i++)
                    {
                        applicationIcons[i] = exampleIcon;
                    }

                    PlayerSettings.SetIconsForTargetGroup(
                        buildTargetGroup, applicationIcons, IconKind.Application);
                    break;
                }
            }
        }
예제 #22
0
        internal static void BuildProxyServer()
        {
            // Check for player support
            if (!CanBuildTarget(EditorUserBuildSettings.activeBuildTarget))
            {
                Debug.LogErrorFormat(CannotBuildErrorMessage, ProxyServerProductName, EditorUserBuildSettings.activeBuildTarget);
                return;
            }

            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);

            // Get folder path from the user for the build
            var folderPath = GetBuildLocation(ProxyServerProductName);

            if (string.IsNullOrEmpty(folderPath))
            {
                return;
            }

            // Cache values for the current Player Settings
            var originalProductName = PlayerSettings.productName;
            var bundleVersion       = PlayerSettings.bundleVersion;
            var appId     = PlayerSettings.GetApplicationIdentifier(buildTargetGroup);
            var iconGroup = PlayerSettings.GetIconsForTargetGroup(buildTargetGroup);

            // Override Player Settings for this build.
            EditorBuildSettingsScene[] buildScenes;
            if (SetBuildSettingsForWearableProxy(out buildScenes))
            {
                var sceneAssetPaths = buildScenes.Where(x => x.enabled).Select(x => x.path).ToArray();

                // Attempt to build the app
                var buildPlayerOptions = new BuildPlayerOptions
                {
                    scenes           = sceneAssetPaths,
                    locationPathName = folderPath,
                    target           = EditorUserBuildSettings.activeBuildTarget
                };

                var buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);

                                #if UNITY_2018_1_OR_NEWER
                if (buildReport.summary.result == BuildResult.Succeeded)
                                #else
                if (string.IsNullOrEmpty(buildReport))
                                #endif
                {
                    Debug.LogFormat(BuildSucceededMessage, ProxyServerProductName);
                }
                else
                {
                    Debug.LogFormat(BuildFailedMessage, ProxyServerProductName, buildReport);
                }
            }

            // Reset all PlayerSetting changes back to their original values.
            PlayerSettings.productName   = originalProductName;
            PlayerSettings.bundleVersion = bundleVersion;
            PlayerSettings.SetApplicationIdentifier(buildTargetGroup, appId);
            PlayerSettings.SetIconsForTargetGroup(buildTargetGroup, iconGroup);
            AssetDatabase.SaveAssets();
        }
예제 #23
0
    static void GenerateAPKFunction()
    {
        string[] Args = System.Environment.GetCommandLineArgs();
        Debug.Log(Args.Length.ToString());
        string iconname     = "";
        string key          = "";
        string keyaliasName = "";
        string keyaliasPass = "";
        string keystorePass = "";

        for (int i = 0; i < Args.Length; i++)
        {
            if (Args[i].Contains("-PARTERICON") && i + 1 < Args.Length)
            {
                iconname = Args[i + 1];
            }
            if (Args[i].Contains("-KEYFILE") && i + 1 < Args.Length)
            {
                key = Args[i + 1];
            }
            if (Args[i].Contains("-KEYALIASNAME") && i + 1 < Args.Length)
            {
                keyaliasName = Args[i + 1];
            }
            if (Args[i].Contains("-KEYALIASPASS") && i + 1 < Args.Length)
            {
                keyaliasPass = Args[i + 1];
            }
            if (Args[i].Contains("-KEYSTOREPASS") && i + 1 < Args.Length)
            {
                keystorePass = Args[i + 1];
            }
            Debug.Log(Args[i]);
        }


        for (int i = 0; i < Args.Length; i++)
        {
            Debug.Log(Args[i]);
        }
        string    ICON_path = "Assets\\Art_new\\UI\\icon\\" + iconname + ".png";
        Texture2D t         = (Texture2D)AssetDatabase.LoadAssetAtPath(ICON_path, typeof(Texture2D));

        Texture2D[] ts = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Android);
        for (int i = 0; i < ts.Length; i++)
        {
            ts[i] = t;
        }


        //set quality
        string[] names = QualitySettings.names;
        for (int i = 0; i < names.Length; i++)
        {
            if (names[i] == "Good")
            {
                QualitySettings.SetQualityLevel(i);
            }
        }
        QualitySettings.pixelLightCount = 1;
        QualitySettings.blendWeights    = BlendWeights.TwoBones;
        QualitySettings.vSyncCount      = 0;
        QualitySettings.antiAliasing    = 0;


        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, ts);
        PlayerSettings.Android.keyaliasName             = keyaliasName; //"lianwu";
        PlayerSettings.Android.keyaliasPass             = keyaliasPass; //"lianwu20130624";
        PlayerSettings.Android.keystorePass             = keystorePass; //"DDLE_LW_20130624";
        PlayerSettings.Android.keystoreName             = key;
        PlayerSettings.Android.useAPKExpansionFiles     = false;
        PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.Auto;
        string[] scenes =
        {
            "Assets/Scenes/logo.unity"
            , "Assets/Scenes/GameStart.unity"
            , "Assets/Scenes/EmptyScene.unity"
        };
        GenerateAndroidAsset._GenerateAndroidAsset();
        EditorUserBuildSettings.androidBuildSubtarget = AndroidBuildSubtarget.ETC;
        BuildPipeline.BuildPlayer(scenes, "AutoBuilder.APK", BuildTarget.Android, BuildOptions.None);
    }
        private static bool HasIconForTargetGroup(BuildTargetGroup buildTargetGroup)
        {
            var icons = PlayerSettings.GetIconsForTargetGroup(buildTargetGroup);

            return(icons != null && icons.Any(icon => icon != null));
        }
예제 #25
0
	static bool PreprocessBuild ()
	{

		try {

			// Save the settings cause we might have changed them
			// This will also propagate the runtime settings so they can be included in the build
			HeadlessEditor.SaveSettings (headlessSettings, HeadlessProfiles.currentProfile);

			System.IO.File.WriteAllText(backupFolder + "/lock.txt", "The existence of this file means that a backup was created and not (yet) reverted.");


			// Backup the graphics settings cause changing the platform sometimes modifies them
			BackupFile (projectFolder + "/ProjectSettings/GraphicsSettings.asset");

			if (headlessSettings.valueAudio) {
				// Disable audio if this feature is enabled in the settings

				BackupFile (projectFolder + "/ProjectSettings/AudioManager.asset");

				var audioManager = AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/AudioManager.asset") [0];
				var serializedManager = new SerializedObject (audioManager);
				var prop = serializedManager.FindProperty ("m_DisableAudio");
				prop.boolValue = true;
				serializedManager.ApplyModifiedProperties ();

				UnityEngine.Debug.Log ("Disabled audio rendering\nHeadless Builder (v" + Headless.version + ")");
			}

			if (headlessSettings.valueGI) {
				// Disable global illumination if this feature is enabled in the settings

				if (UnityEditor.EditorSettings.serializationMode == UnityEditor.SerializationMode.ForceText) {

					foreach (var sceneAsset in sceneAssets) {
						BackupFile (projectFolder + "/" + sceneAsset);
						ProcessScene (projectFolder + "/" + sceneAsset);
					}

					UnityEngine.Debug.Log ("Disabled global illumination\nHeadless Builder (v" + Headless.version + ")");

				} else {
					UnityEngine.Debug.LogWarning ("Disabling global illumination was skipped, because the serialization mode is not set to 'Force Text'\nHeadless Builder (v" + Headless.version + ")");
				}
			}

			if (!debugBuild && headlessSettings.valueDummy) {
				// Replace assets with dummies if this feature is enabled in the settings

				sizeOriginal = 0;
				sizeDummy = 0;
				replaceCount = 0;
				skipDummy = new List<string> ();

				Texture2D[] icons = PlayerSettings.GetIconsForTargetGroup (BuildTargetGroup.Unknown);
				foreach (Texture2D icon in icons) {
					skipDummy.Add (NormalizePath (projectFolder + "/" + AssetDatabase.GetAssetPath (icon)));
				}
				icons = PlayerSettings.GetIconsForTargetGroup (BuildPipeline.GetBuildTargetGroup (buildTarget));
				foreach (Texture2D icon in icons) {
					skipDummy.Add (NormalizePath (projectFolder + "/" + AssetDatabase.GetAssetPath (icon)));
				}

				FindDummies (dummyFolder);
				ProcessDirectory (assetsFolder);

				UnityEngine.Debug.Log ("Replaced " + replaceCount + " assets totaling " + (Mathf.Round (sizeOriginal / 1024 / 1024)) + " MB with " + (Mathf.Round (sizeDummy / 1024 / 1024)) + " MB worth of dummy files\nHeadless Builder (v" + Headless.version + ")");
			}


			// Backup the project settings to revert defines later
			BackupFile (projectFolder + "/ProjectSettings/ProjectSettings.asset");

			string symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildPipeline.GetBuildTargetGroup(buildTarget));
			string[] symbolArray = symbols.Split(new String[]{";"}, StringSplitOptions.None);
			if (!symbolArray.Contains("HEADLESS")) {
				symbols += ";HEADLESS";
			}
			if (!symbolArray.Contains("HEADLESS_" + headlessSettings.profileName.ToUpper())) {
				symbols += ";HEADLESS_" + headlessSettings.profileName.ToUpper();
			}
			PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildPipeline.GetBuildTargetGroup(buildTarget), symbols);


			// Reload the assets to reflect the changes
			AssetDatabase.Refresh ();

			if (manualBuild && currentScene.Length > 0) {
				// If this is a manual build, reload the scene if a scene was loaded
				EditorSceneManager.OpenScene (currentScene);
			}

			SetProgress ("BUILD");

			return true;
		} catch (Exception e) {
			UnityEngine.Debug.LogError (e);
			return false;
		}
	}
예제 #26
0
    static void DoSomething()
    {
        PlayerSettings.showUnitySplashScreen = false;

        DisableAnalytics();

        var pname = PlayerSettings.productName;


        BuildDirectories();

        var icons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Standalone);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "");
        string[] levels = EditorBuildSettings.scenes.Select(s => s.path).ToArray();
        print("building win32");
        BuildPipeline.BuildPlayer(levels, "../Build/" + pname + "/Win/Win_32/" + pname + "/" + pname + ".exe", BuildTarget.StandaloneWindows, BuildOptions.None);
        print("building win64");
        BuildPipeline.BuildPlayer(levels, "../Build/" + pname + "/Win/Win_64/" + pname + "/" + pname + ".exe", BuildTarget.StandaloneWindows64, BuildOptions.None);
        print("building linux");
        BuildPipeline.BuildPlayer(levels, "../Build/" + pname + "/Linux/" + pname + "/" + pname, BuildTarget.StandaloneLinuxUniversal, BuildOptions.None);
        print("building osx");
        BuildPipeline.BuildPlayer(levels, "../Build/" + pname + "/OSX/" + pname, BuildTarget.StandaloneOSX, BuildOptions.None);

        if (File.Exists("readme.txt") == false)
        {
            File.WriteAllText("readme.txt", "from https://www.increpare.com. \n\nThank you very much for playing :) \n\nConsider donating some cash to https://www.patreon.com/increpare if you want to support my work further.");
        }


        File.Copy("readme.txt", "../Build/" + pname + "/Win/Win_32/" + pname + "/readme.txt", true);
        File.Copy("readme.txt", "../Build/" + pname + "/Win/Win_64/" + pname + "/readme.txt", true);
        File.Copy("readme.txt", "../Build/" + pname + "/Linux/" + pname + "/readme.txt", true);
        File.Copy("readme.txt", "../Build/" + pname + "/OSX/readme.txt", true);


        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "STEAM");


        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "");

        try
        {
            File.Delete("../Build/" + pname + "_linux.zip");
        }
        catch (System.Exception e) {
        }

        try
        {
            File.Delete("../Build/" + pname + "_osx.zip");
        }
        catch (System.Exception e) {
        }

        try
        {
            File.Delete("../Build/" + pname + "_win32.zip");
        }
        catch (System.Exception e) {
        }


        try
        {
            File.Delete("../Build/" + pname + "_win64.zip");
        }
        catch (System.Exception e) {
        }

        try
        {
            File.Delete("../Build/" + pname + "_src.zip");
        }
        catch (System.Exception e) {
        }
        //var escapedpname = pname.Replace(" ","\\ ");

        ProcessStartInfo startInfo;


        var dir = new DirectoryInfo("../Build/" + pname + "/Win/Win_64/" + pname);

        foreach (var file in dir.GetFiles("*.pdb"))
        {
            print(file.Name);
            file.Delete();
        }


        dir = new DirectoryInfo("../Build/" + pname + "/Win/Win_32/" + pname);

        foreach (var file in dir.GetFiles("*.pdb"))
        {
            print(file.Name);
            file.Delete();
        }


        print("compressing linux");
        startInfo = new ProcessStartInfo("/usr/bin/tar");
        startInfo.WorkingDirectory = "../Build/" + pname + "/Linux";
        startInfo.Arguments        = "-czvf \"../" + pname + "_linux.tar.gz\" \"" + pname + "\"";
        Process.Start(startInfo).WaitForExit();

        print("compressing osx");
        startInfo = new ProcessStartInfo("/usr/bin/zip");
        startInfo.WorkingDirectory = "../Build/" + pname + "/OSX";
        startInfo.Arguments        = "-r \"../" + pname + "_osx.zip\" \"" + pname + ".app\"";
        Process.Start(startInfo).WaitForExit();

        print("compressing windows");
        startInfo = new ProcessStartInfo("/usr/bin/zip");
        startInfo.WorkingDirectory = "../Build/" + pname + "/Win/Win_32";
        startInfo.Arguments        = "-r \"../../" + pname + "_win32.zip\" \"" + pname + "\"";
        Process.Start(startInfo).WaitForExit();

        print("compressing win");
        startInfo = new ProcessStartInfo("/usr/bin/zip");
        startInfo.WorkingDirectory = "../Build/" + pname + "/Win/Win_64";
        startInfo.Arguments        = "-r \"../../" + pname + "_win64.zip\" \"" + pname + "\"";
        Process.Start(startInfo).WaitForExit();


        print("compressing src");
        dir = new DirectoryInfo(Application.dataPath + "/../");
        var dirName = dir.Name;

        startInfo = new ProcessStartInfo("/usr/bin/zip");
        startInfo.WorkingDirectory = Application.dataPath + "/../../";
        startInfo.Arguments        = "-r \"Build/" + pname + "/" + pname + "_src.zip\" " + dirName;
        Process.Start(startInfo).WaitForExit();
        print("done");
    }
예제 #27
0
        internal static void BuildWearableDemo()
        {
            // Check for player support
            if (!CanBuildTarget(EditorUserBuildSettings.activeBuildTarget))
            {
                Debug.LogErrorFormat(CANNOT_BUILD_ERROR_MESSAGE, WEARABLE_DEMO_PRODUCT_NAME, EditorUserBuildSettings.activeBuildTarget);
                return;
            }

            // Get folder path from the user for the build
            var folderPath = GetBuildLocation(WEARABLE_DEMO_PRODUCT_NAME);

            if (string.IsNullOrEmpty(folderPath))
            {
                return;
            }

            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);

            // Cache values for the current Player Settings
            var originalProductName = PlayerSettings.productName;
            var bundleVersion       = PlayerSettings.bundleVersion;
            var appId     = PlayerSettings.GetApplicationIdentifier(buildTargetGroup);
            var iconGroup = PlayerSettings.GetIconsForTargetGroup(buildTargetGroup);

            var showSplash          = PlayerSettings.SplashScreen.show;
            var splashStyle         = PlayerSettings.SplashScreen.unityLogoStyle;
            var splashColor         = PlayerSettings.SplashScreen.backgroundColor;
            var splashAnimationMode = PlayerSettings.SplashScreen.animationMode;
            var splashDrawMode      = PlayerSettings.SplashScreen.drawMode;
            var splashLogos         = PlayerSettings.SplashScreen.logos;

            // Override Player Settings for this build.
            EditorBuildSettingsScene[] buildScenes;
            if (SetBuildSettingsForWearableDemo(out buildScenes))
            {
                var sceneAssetPaths = buildScenes.Where(x => x.enabled).Select(x => x.path).ToArray();

                // Attempt to build the app
                var buildPlayerOptions = new BuildPlayerOptions
                {
                    scenes           = sceneAssetPaths,
                    locationPathName = folderPath,
                    target           = EditorUserBuildSettings.activeBuildTarget
                };

                var buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);
                                #if UNITY_2018_1_OR_NEWER
                if (buildReport.summary.result == BuildResult.Succeeded)
                                #else
                if (string.IsNullOrEmpty(buildReport))
                                #endif
                {
                    Debug.LogFormat(BUILD_SUCCEEDED_MESSAGE, WEARABLE_DEMO_PRODUCT_NAME);
                }
                else
                {
                    Debug.LogFormat(BUILD_FAILED_MESSAGE, WEARABLE_DEMO_PRODUCT_NAME, buildReport);
                }
            }
            else
            {
                Debug.LogErrorFormat(BUILD_SCENES_COULD_NOT_BE_FOUND, WEARABLE_DEMO_PRODUCT_NAME);
            }

            // Reset all PlayerSetting changes back to their original values.
            PlayerSettings.productName   = originalProductName;
            PlayerSettings.bundleVersion = bundleVersion;
            PlayerSettings.SetApplicationIdentifier(buildTargetGroup, appId);
            PlayerSettings.SetIconsForTargetGroup(buildTargetGroup, iconGroup);

            PlayerSettings.SplashScreen.show            = showSplash;
            PlayerSettings.SplashScreen.unityLogoStyle  = splashStyle;
            PlayerSettings.SplashScreen.backgroundColor = splashColor;
            PlayerSettings.SplashScreen.animationMode   = splashAnimationMode;
            PlayerSettings.SplashScreen.drawMode        = splashDrawMode;
            PlayerSettings.SplashScreen.logos           = splashLogos;

            AssetDatabase.SaveAssets();
        }
예제 #28
0
    public static bool SaveProject(bool add, ProjectBuildData data)
    {
        DataRow   drProject = null;
        DataTable dt        = LoadAndCreateProjects(PROJECTS_CONFIG_FILE);

        foreach (DataRow dr in dt.Rows)
        {
            string name = dr["ProjectName"].ToString();
            if (name == data.Name)
            {
                drProject = dr;
                break;
            }
        }

        if (add && drProject != null)
        {
            Debug.LogError("exist same project name already " + data.Name);
            return(false);
        }
        else if (!add && drProject == null)
        {
            Debug.LogError("project not exist " + data.Name);
            return(false);
        }
        else if (add)
        {
            drProject = dt.NewRow();
            dt.Rows.Add(drProject);
        }

        drProject["ProjectName"] = data.Name;
        drProject["Version"]     = data.Version;

        List <string> sceneList = new List <string>();

        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            if (!scene.enabled)
            {
                continue;
            }
            sceneList.Add(scene.path);
        }
        string scenes = string.Join(";", sceneList.ToArray());

        drProject["Scenes"] = scenes;

        drProject["Target"]       = EditorUserBuildSettings.activeBuildTarget;
        drProject["SymbolDefine"] = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
        drProject["DebugBuild"]   = EditorUserBuildSettings.development.ToString();

        FieldInfo[] optionFields = typeof(GameOptions).GetFields();
        foreach (var field in optionFields)
        {
            if (!field.IsPublic || field.IsStatic)
            {
                continue;
            }

            if (!dt.Columns.Contains(field.Name))
            {
                dt.Columns.Add(field.Name);
            }

            var obj = field.GetValue(data.Options);
            if (obj != null)
            {
                if (field.FieldType == typeof(string) ||
                    field.FieldType == typeof(bool) ||
                    field.FieldType == typeof(int) ||
                    field.FieldType.IsEnum)
                {
                    drProject[field.Name] = obj.ToString();
                }
                else if (field.FieldType.IsGenericType)
                {
                    drProject[field.Name] = LitJson.JsonMapper.ToJson(obj);
                }
            }
        }

        PropertyInfo[] fields = typeof(PlayerSettings).GetProperties(BindingFlags.Public | BindingFlags.Static);
        foreach (var field in fields)
        {
            if (!field.CanWrite)
            {
                continue;
            }

            var obj = field.GetValue(null, null);
            if (obj != null)
            {
                drProject[field.Name] = obj.ToString();
                if (field.PropertyType == typeof(Texture2D))
                {
                    var texture = obj as Texture2D;
                    drProject[field.Name] = texture.name;
                }
            }
        }

        var types = typeof(PlayerSettings).GetNestedTypes();

        foreach (var type in types)
        {
            var sb     = new StringBuilder();
            var writer = new LitJson.JsonWriter(sb);

            writer.WriteObjectStart();

            var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Static);
            foreach (var property in properties)
            {
                if (!property.CanWrite)
                {
                    continue;
                }

                writer.WritePropertyName(property.Name);
                var obj = property.GetValue(null, null);
                writer.Write(obj != null ? obj.ToString() : "");
            }

            writer.WriteObjectEnd();

            if (!drProject.Table.Columns.Contains(type.Name))
            {
                drProject.Table.Columns.Add(type.Name);
            }
            drProject[type.Name] = sb.ToString();
        }

        var iconList = new List <string>();
        var group    = GetBuildGroupByTarget(data.Target);
        var icons    = PlayerSettings.GetIconsForTargetGroup(group);

        foreach (var texture2D in icons)
        {
            if (texture2D != null)
            {
                var path = AssetDatabase.GetAssetPath(texture2D.GetInstanceID());
                iconList.Add(path);
            }
        }

        var iconsStr = string.Join(",", iconList.ToArray());

        drProject["Icons"] = iconsStr;

        if (data.Games != null)
        {
            var str = LitJson.JsonMapper.ToJson(data.Games);
            drProject["Games"] = str;
        }

        SaveToDB(dt, PROJECTS_CONFIG_FILE);

        //SaveConfig(data);

        return(true);
    }
 public static string CurrentSettingsAsCSV()
 {
     #region shared
     string output = "Platform," + currentPlatform + "\n";
     output += "defaultIcon," + AssetDatabase.GetAssetPath(PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown)[0]) + "\n";
     output += "scriptingDefineSymbols," + PlayerSettings.GetScriptingDefineSymbolsForGroup(currentPlatform) + "\n";
     output += "companyName," + PlayerSettings.companyName + "\n";
     output += "productName," + PlayerSettings.productName + "\n";
     output += "iPhoneBundleIdentifier," + PlayerSettings.iPhoneBundleIdentifier + "\n";
     output += "keystorePass," + PlayerSettings.keystorePass + "\n";
     output += "keyaliasPass," + PlayerSettings.keyaliasPass + "\n";
     output += "bundleVersion," + PlayerSettings.bundleVersion + "\n";
     output += "bundleIdentifier," + PlayerSettings.bundleIdentifier + "\n";
     output += "statusBarHidden," + PlayerSettings.statusBarHidden + "\n";
     output += "defaultInterfaceOrientation," + PlayerSettings.defaultInterfaceOrientation + "\n";
     output += "allowedAutorotateToPortrait," + PlayerSettings.allowedAutorotateToPortrait + "\n";
     output += "allowedAutorotateToPortraitUpsideDown," + PlayerSettings.allowedAutorotateToPortraitUpsideDown + "\n";
     output += "allowedAutorotateToLandscapeRight," + PlayerSettings.allowedAutorotateToLandscapeRight + "\n";
     output += "allowedAutorotateToLandscapeLeft," + PlayerSettings.allowedAutorotateToLandscapeLeft + "\n";
     output += "useAnimatedAutorotation," + PlayerSettings.useAnimatedAutorotation + "\n";
     output += "use32BitDisplayBuffer," + PlayerSettings.use32BitDisplayBuffer + "\n";
     output += "targetGlesGraphics," + PlayerSettings.targetGlesGraphics + "\n";
     output += "apiCompatibilityLevel," + PlayerSettings.apiCompatibilityLevel + "\n";
     output += "stripUnusedMeshComponents," + PlayerSettings.stripUnusedMeshComponents + "\n";
     output += "aotOptions," + PlayerSettings.aotOptions + "\n";
     output += "accelerometerFrequency," + PlayerSettings.accelerometerFrequency + "\n";
     output += "MTRendering," + PlayerSettings.MTRendering + "\n";
     output += "mobileMTRendering," + PlayerSettings.mobileMTRendering + "\n";
     output += "renderingPath," + PlayerSettings.renderingPath + "\n";
     output += "mobileRenderingPath," + PlayerSettings.renderingPath + "\n";
     output += "useDirect3D11," + PlayerSettings.useDirect3D11 + "\n";
     output += "stereoscopic3D," + PlayerSettings.stereoscopic3D + "\n";
     #endregion
     if (currentPlatform == BuildTargetGroup.Android)
     {
         #region android
         output += "Android.use24BitDepthBuffer," + PlayerSettings.Android.use24BitDepthBuffer + "\n";
         output += "Android.bundleVersionCode," + PlayerSettings.Android.bundleVersionCode + "\n";
         output += "Android.minSdkVersion," + PlayerSettings.Android.minSdkVersion + "\n";
         output += "Android.preferredInstallLocation," + PlayerSettings.Android.preferredInstallLocation + "\n";
         output += "Android.forceInternetPermission," + PlayerSettings.Android.forceInternetPermission + "\n";
         output += "Android.forceSDCardPermission," + PlayerSettings.Android.forceSDCardPermission + "\n";
         output += "Android.targetDevice," + PlayerSettings.Android.targetDevice + "\n";
         output += "Android.splashScreenScale," + PlayerSettings.Android.splashScreenScale + "\n";
         output += "Android.keystoreName," + PlayerSettings.Android.keystoreName + "\n";
         output += "Android.keystorePass," + PlayerSettings.Android.keystorePass + "\n";
         output += "Android.keyaliasName," + PlayerSettings.Android.keyaliasName + "\n";
         output += "Android.keyaliasPass," + PlayerSettings.Android.keyaliasPass + "\n";
         output += "Android.useAPKExpansionFiles," + PlayerSettings.Android.useAPKExpansionFiles + "\n";
         output += "Android.showActivityIndicatorOnLoading," + PlayerSettings.Android.showActivityIndicatorOnLoading;
         #endregion
     }
     else if (currentPlatform == BuildTargetGroup.iPhone)
     {
         #region iOS
         output += "iOS.applicationDisplayName," + PlayerSettings.iOS.applicationDisplayName + "\n";
         output += "iOS.scriptCallOptimization," + PlayerSettings.iOS.scriptCallOptimization + "\n";
         output += "iOS.sdkVersion," + PlayerSettings.iOS.sdkVersion + "\n";
         output += "iOS.targetOSVersion," + PlayerSettings.iOS.targetOSVersion + "\n";
         output += "iOS.targetDevice," + PlayerSettings.iOS.targetDevice + "\n";
         output += "iOS.targetResolution," + PlayerSettings.iOS.targetResolution + "\n";
         output += "iOS.prerenderedIcon," + PlayerSettings.iOS.prerenderedIcon + "\n";
         output += "iOS.requiresPersistentWiFi," + PlayerSettings.iOS.requiresPersistentWiFi + "\n";
         output += "iOS.statusBarStyle," + PlayerSettings.iOS.statusBarStyle + "\n";
         output += "iOS.exitOnSuspend," + PlayerSettings.iOS.exitOnSuspend + "\n";
         output += "iOS.showActivityIndicatorOnLoading," + PlayerSettings.iOS.showActivityIndicatorOnLoading;
         #endregion
     }
     return(output);
 }
예제 #30
0
    static void BulidTarget(BuilderTager _BuilderTager, BuildTarget buildTarget = BuildTarget.StandaloneWindows)
    {
        string           applicationPath = string.Format("{0}/Setup/", Application.dataPath.Replace("/Assets", ""));
        string           iconPath        = "Assets/Pic/";
        string           target_name     = "";
        BuildTargetGroup targetGroup     = BuildTargetGroup.Standalone;
        string           target_dir      = "";

        if (buildTarget == BuildTarget.StandaloneWindows)
        {
            target_name = _BuilderTager.ToString() + ".exe";
            targetGroup = BuildTargetGroup.Standalone;
            target_dir  = applicationPath + "PC";
        }



        if (buildTarget == BuildTarget.Android)
        {
            target_dir  = applicationPath + "Android";
            target_name = _BuilderTager.ToString() + ".apk";
            targetGroup = BuildTargetGroup.Android;
        }

        if (buildTarget == BuildTarget.iOS)
        {
            target_dir  = applicationPath + "IOS";
            target_name = _BuilderTager.ToString();
            targetGroup = BuildTargetGroup.iOS;
            buildTarget = BuildTarget.iOS;
        }

        if (target_name.Equals("") || target_dir.Equals(""))
        {
            Debug.LogError("target_name  is  null  or   target_dir  is  null");
            return;
        }

        if (Directory.Exists(target_dir))
        {
            if (File.Exists(target_name))
            {
                File.Delete(target_name);
            }
        }
        else
        {
            Directory.CreateDirectory(target_dir);
        }


        string oldtargetGroup = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);

        foreach (BuilderTager item in Enum.GetValues(typeof(BuilderTager)))
        {
            oldtargetGroup = oldtargetGroup.Replace(string.Format("{0};", item.ToString()), "");
        }


        switch (_BuilderTager)
        {
        case BuilderTager.BuilHX_Android:        //C+S
            iconPath = iconPath + "HX_Android";
            PlayerSettings.applicationIdentifier = "com.jiteng.shapan";
            PlayerSettings.bundleVersion         = ver.ToString("F2");

            PlayerSettings.productName = "互享";

            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Format("{0};{1}", _BuilderTager.ToString(), oldtargetGroup));
            PlayerSettings.runInBackground = true;
            break;

        case BuilderTager.BuilHX_IOS:        //C+S
            iconPath = iconPath + "HX_IOS";
            PlayerSettings.applicationIdentifier = "com.jiteng.shapan";
            PlayerSettings.bundleVersion         = ver.ToString("F2");
            PlayerSettings.productName           = "互享";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Format("{0};{1}", _BuilderTager.ToString(), oldtargetGroup));
            PlayerSettings.runInBackground     = true;
            PlayerSettings.forceSingleInstance = true;

            break;

        case BuilderTager.BuilDTGL_Android:                                  //C
            iconPath = iconPath + "DTGL_Android";
            PlayerSettings.applicationIdentifier = "com.woling.CourseTrain"; //Train
            PlayerSettings.bundleVersion         = ver.ToString("F2");
            PlayerSettings.productName           = "地铁概论";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Format("{0};{1}", _BuilderTager.ToString(), oldtargetGroup));
            PlayerSettings.runInBackground           = true;
            PlayerSettings.forceSingleInstance       = true;
            PlayerSettings.Android.bundleVersionCode = versionCode;
            break;

        case BuilderTager.BuilDTGL_IOS:    //C+S
            iconPath = iconPath + "DTGL_IOS";
            PlayerSettings.applicationIdentifier = "com.woling.CourseTrain";
            PlayerSettings.bundleVersion         = ver.ToString("F2");
            PlayerSettings.productName           = "地铁概论";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Format("{0};{1}", _BuilderTager.ToString(), oldtargetGroup));
            PlayerSettings.runInBackground           = true;
            PlayerSettings.forceSingleInstance       = true;
            PlayerSettings.Android.bundleVersionCode = versionCode;
            break;

        case BuilderTager.BuildPC_Tools:
            iconPath = iconPath + "PCTOOLS";
            PlayerSettings.applicationIdentifier = "com.woling.CourseTrain";
            PlayerSettings.bundleVersion         = ver.ToString("F2");
            PlayerSettings.productName           = "管理工具";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Format("{0};{1}", _BuilderTager.ToString(), oldtargetGroup));
            PlayerSettings.runInBackground     = true;
            PlayerSettings.forceSingleInstance = true;
            break;
        }
        Texture2D[] icon = PlayerSettings.GetIconsForTargetGroup(targetGroup);
        for (int i = 0; i < icon.Length; i++)
        {
            icon[i] = (Texture2D)AssetDatabase.LoadAssetAtPath(iconPath + "/" + i + ".png", typeof(Texture2D));
        }
        PlayerSettings.SetIconsForTargetGroup(targetGroup, icon);
        GenericBuild(FindEnabledEditorScenes(_BuilderTager), target_dir + "/" + target_name, buildTarget, BuildOptions.None, targetGroup, oldtargetGroup);
    }