赞
踩
大家先熟悉 下这个 [InitializeOnLoad] 。 这个标签 是 Unity3D刚打开 或者 运行时候的回调;那我们就给予它开始代码
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using System.IO; using BoTing.Updater; [InitializeOnLoad] public static class ProjectAutoSetting { static ProjectAutoSetting() { //EditorUserBuildSettings.activeBuildTargetChanged = delegate () { // if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) // { // Debug.Log("DoSomeThings"); // } //}; //EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); //EditorUserBuildSettings.activeBuildTargetChanged += OnAutoSetting; OnAutoSetting(); } static void OnAutoSetting() { if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { OnAndroid(); } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS) { OnIOS(); } } static void OnAndroid() { //Debug.Log("OnAndroid"); DirectoryInfo dir = Directory.GetParent(Application.dataPath).Parent; string path = dir.ToString() + @"\KeyStore\user_Phoenix.keystore";//自己的路径 //Debug.Log(path); if (File.Exists(path)) { PlayerSettings.Android.keystoreName = path; PlayerSettings.Android.keyaliasName = "phoenix"; PlayerSettings.keystorePass = "youxi9123"; PlayerSettings.keyaliasPass = "phoenix9123"; PlayerSettings.applicationIdentifier = "com.fenghuang.yule"; PlayerSettings.companyName = "912娱乐"; PlayerSettings.productName = "凤凰竞技娱乐"; PlayerSettings.bundleVersion = UpdaterConfig.AppVersion;//这里这几根据项目设置 我这里有全局的 PlayerSettings.Android.bundleVersionCode = int.Parse(System.DateTime.Now.ToString("yyMMddHHmm")); } string outPath = Directory.GetParent(Application.dataPath).Parent.ToString() + "/" + PlayerSettings.productName + "_" + System.DateTime.Now.ToString("yyyyMMddHHmm"); EditorUserBuildSettings.SetBuildLocation(BuildTarget.Android, outPath); } static void OnIOS() { //Debug.Log("OnIOS"); PlayerSettings.applicationIdentifier = "com.fenghuang.yule"; PlayerSettings.bundleVersion = "1.9.115"; PlayerSettings.iOS.applicationDisplayName = "凤凰竞技娱乐"; PlayerSettings.iOS.targetOSVersionString = "8"; PlayerSettings.iOS.buildNumber = System.DateTime.Now.ToString("yyyyMMddHHmm"); PlayerSettings.iOS.sdkVersion = iOSSdkVersion.DeviceSDK; } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。