Example #1
0
        private static void InitForAndroidBuild()
        {
            // 初始化打包信息
            BuildSettings.GetInstance(BuildSettings.AssetFileDir);

#if UNITY_ANDROID
            // 设定选项
            // 天鸽的场合
            if (PlatformType.Tiange == SysSettings.GetInstance().PlatformType)
            {
                // 初始化SDK设定信息&导入最新
                TiangeSdkSettings.GetInstance(TiangeSdkSettings.AssetFileDir).ImportFromJsonFile();
                Loger.BuildLog("TiangeSdkSettings -> ImportFromJsonFile().");
                var oneSDk         = TiangeSdkSettings.GetInstance().data.Options.IsOptionValid(SDKOptions.OneSDK);
                var metaDatasCount = TiangeSdkSettings.GetInstance().data.Options.OneSDK.metaDatas.Count;
                Loger.BuildLog($"TiangeSdkSettings::OneSDK:{oneSDk}(MetaData:{metaDatasCount}).");

                TiangeSdkSettings.GetInstance().data.Options.data =
                    SysSettings.GetInstance().data.Options.data;
            }

            // 清空Plugins/Android目录
            ClearPluginsAndroid();

            // 重置Plugins/Android
            ResetPluginsAndroid();

            // 设置相关AndroidSDK相关设定
            var androidSdk = GetCurAndroidSdkSetting();
            if (androidSdk != null)
            {
                var gameName    = SysSettings.GetInstance().BuildName;
                var packageName = SysSettings.GetInstance().BuildId;
                // 打包Android(apk文件)之前,提前应用设定
                androidSdk.PreApplyAndroidBuild(gameName, packageName);
            }
            else
            {
                Loger.BuildWarningLog("Android SDK invalid!!");
            }
#endif

            // 刷新
            UtilsAsset.AssetsRefresh();
        }
Example #2
0
        /// <summary>
        /// 取得当前AndroidSDK设定信息.
        /// </summary>
        /// <returns>当前AndroidSDK设定信息.</returns>
        private static IAndroidSdkSettings GetCurAndroidSdkSetting()
        {
            IAndroidSdkSettings settings = null;

            // 平台类型
            var platformType = SysSettings.GetInstance().PlatformType;

            Loger.BuildLog($"PlatformType:{platformType}.");

            switch (platformType)
            {
            // 华为
            case PlatformType.Huawei:
            {
                settings = HuaweiSdkSettings.GetInstance(HuaweiSdkSettings.AssetFileDir);
            }
            break;

            // 天鸽
            case PlatformType.Tiange:
            {
                settings = TiangeSdkSettings.GetInstance(TiangeSdkSettings.AssetFileDir);
            }
            break;

            case PlatformType.Android:
                break;

            case PlatformType.None:
                break;

            case PlatformType.iOS:
                break;

            default:
            {
                // 清空/Plugins/Android下的文件
            }
            break;
            }

            return(settings);
        }
Example #3
0
        /// <summary>
        /// 初始化SDK版本信息.
        /// </summary>
        /// <returns>SDK版本信息节点.</returns>
        protected override XmlElement InitSdkVersions()
        {
            var useSdkNode = base.InitSdkVersions();

            if (null == useSdkNode)
            {
                return(null);
            }
            if (-1 >= TiangeSdkSettings.GetInstance().MinSdkVersion)
            {
                MinSdkVersion = GetNodeAttribute_i(useSdkNode, "minSdkVersion");
            }
            else
            {
                MinSdkVersion = TiangeSdkSettings.GetInstance().MinSdkVersion;
                SetNodeAttribute(useSdkNode, "minSdkVersion", MinSdkVersion.ToString());
            }
            if (-1 >= TiangeSdkSettings.GetInstance().MaxSdkVersion)
            {
                MaxSdkVersion = GetNodeAttribute_i(useSdkNode, "android:maxSdkVersion");
            }
            else
            {
                MaxSdkVersion = TiangeSdkSettings.GetInstance().MaxSdkVersion;
                SetNodeAttribute(useSdkNode, "maxSdkVersion", MaxSdkVersion.ToString());
            }
            if (-1 >= TiangeSdkSettings.GetInstance().TargetSdkVersion)
            {
                TargetSdkVersion = GetNodeAttribute_i(useSdkNode, "android:targetSdkVersion");
            }
            else
            {
                TargetSdkVersion = TiangeSdkSettings.GetInstance().TargetSdkVersion;
                SetNodeAttribute(useSdkNode, "targetSdkVersion", TargetSdkVersion.ToString());
            }
            return(useSdkNode);
        }
Example #4
0
        /// <summary>
        /// 应用用户自定义数据.
        /// </summary>
        /// <param name="iGameName">游戏名.</param>
        protected override void ApplyUserData(string iGameName)
        {
            // 本地设定
            {
                const string name  = "Local";
                var          value = TiangeSdkSettings.GetInstance().Local.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (TiangeSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }

            // 游戏名
            {
                const string name  = "GameName";
                var          value = iGameName;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }

            // SDK自动初始化
            {
                const string name  = "AutoSdkInit";
                var          value = TiangeSdkSettings.GetInstance().AutoSdkInit.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (TiangeSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }

            // 自动登录
            {
                const string name  = "AutoLogin";
                var          value = TiangeSdkSettings.GetInstance().AutoLogin.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (TiangeSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }
            // 屏幕方向
            {
                const string name        = "Orientation";
                var          value       = "1";
                var          orientation = TiangeSdkSettings.GetInstance().Orientation;
                if (UIOrientation.LandscapeLeft == orientation ||
                    UIOrientation.LandscapeRight == orientation)
                {
                    value = "2";
                }
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
            }

            // 易接SDK 设定
            if (TiangeSdkSettings.GetInstance().data.Options.IsOptionValid(SDKOptions.OneSDK))
            {
                // 易接SDK Key
                {
                    const string name  = "zy_class_name";
                    var          value = TiangeSdkSettings.GetInstance().data.Options.OneSDK.zyClassName;
                    if (false == string.IsNullOrEmpty(value))
                    {
                        AddUserDefineNode(name, value);
                    }
                }

                // 易接SDK MetaDatas
                {
                    var metaDatas = TiangeSdkSettings.GetInstance().data.Options.OneSDK.metaDatas;
                    foreach (var metaData in metaDatas)
                    {
                        if (null != metaData &&
                            false == string.IsNullOrEmpty(metaData.name) &&
                            false == string.IsNullOrEmpty(metaData.value))
                        {
                            AddUserDefineNode(metaData.name, metaData.value, false);
                        }
                    }
                }
            }

            // 保存strings.xml
            StringsXml?.Save();
        }