Пример #1
0
    public static void BuildForAndroid(BuildCollectionResInfo buildInfo)
    {
        Debug.LogError("BuildForAndroid>>start");
        SetBaseMainnifestXml(buildInfo);
        SetUPushMainnifestxml(buildInfo);
        PlayerSettings.Android.useAPKExpansionFiles = false;
        PlayerSettings.Android.keystoreName         = Application.dataPath + "/../xlkj.keystore";
        PlayerSettings.Android.keyaliasPass         = "******";
        PlayerSettings.Android.keystorePass         = "******";
        PlayerSettings.Android.keyaliasName         = "yanshi";

        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, buildInfo.AndroidPackageName);
        string[] scenes = null;
        if (buildInfo.isTrans)
        {
            scenes = GetTransBuildScenes;
            PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevelAuto;
        }
        else
        {
            scenes = GetBuildScenes;
            PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevel22;
        }
        string res = BuildPipeline.BuildPlayer(scenes, outpath, BuildTarget.Android, BuildOptions.None);

        Debug.Log("生成完成" + res);
        Debug.LogError("BuildForAndroid>>end");
    }
Пример #2
0
    public static void BuildCollectionsResByInfo(BuildCollectionResInfo info)
    {
        string              fileName = Application.streamingAssetsPath + "/" + info.CollectionID + "ver.txt";
        List <VerInfo>      allList  = new List <VerInfo>();
        List <BuildResInfo> list     = new List <BuildResInfo>(info.builds);

        for (int i = list.Count - 1; i >= 0; i--)
        {
            BuildInfoAB    build = new BuildInfoAB(list[i]);
            List <VerInfo> infos = build.BuildAb(2);
            foreach (VerInfo _v in infos)
            {
                if (_v != null)
                {
                    allList.Add(_v);
                }
            }
        }
        VerInfo buildinfo = new VerInfo();

        foreach (VerInfo ver in allList)
        {
            buildinfo.ver = ver.ver;
            buildinfo.files.AddRange(ver.files);
        }
        string txtStr = JsonUtility.ToJson(buildinfo, true);

        File.WriteAllText(fileName, txtStr);
        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    }
Пример #3
0
    public static void SetLocalGameCfg(BuildCollectionResInfo buildInfo)
    {
        LocalGameCfgData localdata = Resources.Load <LocalGameCfgData>("gamecfg");

        localdata.chanelType   = Channel;
        localdata.isPublic     = isPublic;
        localdata.collectionID = buildInfo.CollectionID;
        EditorUtility.SetDirty(localdata);
        AssetDatabase.SaveAssets();
    }
Пример #4
0
    public static BuildCollectionResInfo CreateAsste()
    {
        var select = Selection.activeObject;
        var path   = AssetDatabase.GetAssetPath(select);

        path = AssetDatabase.GenerateUniqueAssetPath(path + "/BuildeResInfo.asset");
        BuildCollectionResInfo data = ScriptableObject.CreateInstance <BuildCollectionResInfo>();

        AssetDatabase.CreateAsset(data, path);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        return(data);
    }
Пример #5
0
 public static BuildCollectionResInfo Find(string collectionName)
 {
     string[] bs = AssetDatabase.FindAssets("t:BuildCollectionResInfo");
     foreach (string b in bs)
     {
         BuildCollectionResInfo bc = AssetDatabase.LoadAssetAtPath <BuildCollectionResInfo>(AssetDatabase.GUIDToAssetPath(b));
         if (bc.CollectionName == collectionName)
         {
             return(bc);
         }
     }
     return(null);
 }
Пример #6
0
    public static void SetUmengXinXI(BuildCollectionResInfo buildInfo)
    {
        string         appid          = WXConstant.UMengAppID[buildInfo.CollectionID];
        string         Secret         = WXConstant.UMengPushSecret[buildInfo.CollectionID];
        string         channelstr     = ((ChannelType)Channel).ToString();
        UMConstantInfo uMConstantInfo = new UMConstantInfo();

        uMConstantInfo.appid     = appid;
        uMConstantInfo.secret    = Secret;
        uMConstantInfo.channelid = channelstr;
        string json = JsonUtility.ToJson(uMConstantInfo);

        File.WriteAllText(Application.streamingAssetsPath + "/UMConstant.json", json);
    }
Пример #7
0
    public static void SetUPushMainnifestxml(BuildCollectionResInfo buildInfo)
    {
        string mainnifestRoot = Application.dataPath + "/Plugins/Android/push.plugin/AndroidManifest.xml";
        string mainnifestMode = Application.dataPath + "/../AndroidXMLMode/UpushManifest.xml";

        string mainnifestxml = File.ReadAllText(mainnifestMode);

        Debug.LogError("SetUPushMainnifestxml-> mainnifestxml=" + mainnifestxml);
        mainnifestxml = mainnifestxml
                        .Replace("${applicationId}", buildInfo.AndroidPackageName);

        Debug.LogError("SetUPushMainnifestxml-> Replace =" + mainnifestxml);

        File.WriteAllText(mainnifestRoot, mainnifestxml);
    }
Пример #8
0
    public static void BuildPlayer(BuildCollectionResInfo buildInfo, BuildTargetGroup target)
    {
        BuildTarget ta = BuildTarget.StandaloneWindows;

        switch (target)
        {
        case BuildTargetGroup.Standalone:
            ta = BuildTarget.StandaloneWindows;
            break;

        case BuildTargetGroup.Android:
            ta = BuildTarget.Android;
            break;

        case BuildTargetGroup.iOS:
            ta = BuildTarget.iOS;
            break;

        default:
            ta = BuildTarget.StandaloneWindows;
            break;
        }
        BuildCfgAttributeInfo        baf       = null;
        List <BuildCfgAttributeInfo> buildcfgs = BuildCfgAttribute.GetAllAttribute(ta, Channel,
                                                                                   buildInfo.CollectionID, out baf);

        string[]     scs = null;
        BuildOptions bop = BuildOptions.None;

        if (baf != null)
        {
            PropertyInfo buildpro = baf.type.GetProperty("BuildScenes");
            scs = buildpro.GetValue(baf.obj, null) as string[];
            PropertyInfo op = baf.type.GetProperty("BuildOptions");
            bop = (BuildOptions)op.GetValue(baf.obj, null);
        }
        foreach (BuildCfgAttributeInfo cfg in buildcfgs)
        {
            cfg.obj.BuildBefore();
        }
        scs = scs == null ? GetBuildScenes : scs;

        BuildPipeline.BuildPlayer(scs, outpath, ta, bop);
    }
Пример #9
0
    public static void SetBaseMainnifestXml(BuildCollectionResInfo buildInfo)
    {
        string appid          = WXConstant.UMengAppID[buildInfo.CollectionID];
        string Secret         = WXConstant.UMengPushSecret[buildInfo.CollectionID];
        string xlAppId        = WXConstant.XLAppID[buildInfo.CollectionID];
        string channelstr     = ((ChannelType)Channel).ToString();
        string mainnifestRoot = Application.dataPath + "/Plugins/Android/AndroidManifest.xml";
        string mainnifestMode = Application.dataPath + "/../AndroidXMLMode/AndroidManifest.xml";
        string mainnifestxml  = File.ReadAllText(mainnifestMode);

        mainnifestxml = mainnifestxml.Replace("#packageName#", buildInfo.AndroidPackageName)
                        .Replace("#UMENG_APPKEY", appid)
                        .Replace("#UMENG_MESSAGE_SECRET", Secret)
                        .Replace("#UMENG_CHANNEL", channelstr)
                        .Replace("#JUMPALIPAYSCHEME", buildInfo.jumpScheme)
                        .Replace("#XLAPPID", xlAppId);

        File.WriteAllText(mainnifestRoot, mainnifestxml);
    }
Пример #10
0
    public static void BuildPCALL(string ver, bool ispublic, BuildCollectionResInfo build)
    {
        mDefVersion = ver;
        misPublic   = ispublic;
//         Initialization core = GameObject.Find("GameCore").GetComponent<Initialization>();
//         core.DebugMode = false;
        SetIconAndBg(build);
        build.Build();
#if UNITY_IOS
        BuildForIos(build);
#elif UNITY_ANDROID
        BuildForAndroid(build);
#else
        Debug.LogError(outpath);
        BuildPipeline.BuildPlayer(GetBuildScenes, outpath, BuildTarget.StandaloneWindows64, BuildOptions.None);
#endif
        //core.DebugMode = true;
        System.Diagnostics.Process.Start("explorer", outpath.Substring(0, outpath.LastIndexOf("/")));
    }
Пример #11
0
    //[UnityEditor.MenuItem("Tools/bulid")]
    public static void BuildProjected()
    {
        Debug.LogError("生成AB");
        string assetName = Trans ? (int)currentCollection + "Trans" : (int)currentCollection + "";

        assetName += ".asset";
        BuildCollectionResInfo builfCfg = null;
        string buildCfgpath             = "Assets/YKFramwork/Editor/BuildAbInfo/Collections/"
                                          + assetName;

        builfCfg = AssetDatabase.LoadAssetAtPath <BuildCollectionResInfo>(buildCfgpath);
        if (builfCfg == null)
        {
            Debug.LogError("加载不到builfCfg" + buildCfgpath + "/ccc=" + currentCollection);
            return;
        }

        if (builfCfg)
        {
            SetIconAndBg(builfCfg);
            SetUmengXinXI(builfCfg);
            builfCfg.Build();
        }

        Debug.Log("生成ab完成");
        BuildAB.BuildResIni();
        Debug.Log("准备生成APK");
        //BuildAB.BuildAb();
        if (CurrenBuildTarget == BuildTargetGroup.Android)
        {
            BuildForAndroid(builfCfg);
        }
        else if (CurrenBuildTarget == BuildTargetGroup.iOS)
        {
            BuildForIos(builfCfg);
        }
        else if (CurrenBuildTarget == BuildTargetGroup.Standalone)
        {
        }
    }
Пример #12
0
    public void OnGUI()
    {
        GUILayout.BeginVertical();
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("要生成的版本号:");
                mDefVersion = GUILayout.TextField(mDefVersion);
            } GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                misPublic = GUILayout.Toggle(misPublic, "是否是发布版本");
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                buildCfg = EditorGUILayout.ObjectField(new GUIContent("要生成的版本信息"), buildCfg, typeof(BuildCollectionResInfo), false) as BuildCollectionResInfo;
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("生成"))
            {
                if (buildCfg == null)
                {
                    if (UnityEditor.EditorUtility.DisplayDialog("错误", "请选择要发布的东西", "确认"))
                    {
                        Debug.LogError("------------------");
                    }
                }
                else
                {
                    ProjectBuild.BuildPCALL(mDefVersion, misPublic, buildCfg);
                }
            }
        } GUILayout.EndVertical();
    }
Пример #13
0
    //[UnityEditor.MenuItem("Tools/bulid")]
    public static void BuildProjected()
    {
        //AssetDatabase.FindAssets(currentCollection +"t:"+ BuildCollectionResInfo.)

        BuildCollectionResInfo builfCfg = BuildCollectionResInfo.Find((int)currentCollection);

        if (builfCfg == null)
        {
            Debug.LogError("加载不到builfCfg    " + currentCollection);
            return;
        }

        if (builfCfg)
        {
            builfCfg.Build();
            SetLocalGameCfg(builfCfg);
        }
        Debug.Log("生成ab完成");
        BuildAB.BuildResIni();
        Debug.Log("准备生成APK");
        EditorPrefs.SetInt(savecollection, (int)currentCollection);
        //BuildAB.BuildAb();
        BuildPlayer(builfCfg, CurrenBuildTarget);
    }
Пример #14
0
    /// <summary>
    /// 设置背景图和icon
    /// </summary>
    /// <param name="collectionID">合集id</param>
    //[MenuItem("Tools/setIcon")]
    public static void SetIconAndBg(BuildCollectionResInfo buildInfo)
    {
        PlayerSettings.Android.targetSdkVersion    = AndroidSdkVersions.AndroidApiLevelAuto;
        PlayerSettings.bundleVersion               = InstallVersion;
        PlayerSettings.SplashScreen.show           = false;
        PlayerSettings.stripEngineCode             = false;
        PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;

        PlayerSettings.allowedAutorotateToLandscapeLeft      = true;
        PlayerSettings.allowedAutorotateToLandscapeRight     = true;
        PlayerSettings.allowedAutorotateToPortrait           = false;
        PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;

        PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, true);
        PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.iOS, true);

        int    collectionID = buildInfo.CollectionID;
        string root         = Application.dataPath + "/CollectionEeefctRes";
        string iconRoot     = root + "/Icon/" + collectionID + ".png";

        if (buildInfo.isTrans)
        {
            iconRoot = root + "/Icon/dataIcon.jpg";
        }
        string sharethumbPath = root + "/sharethumb/" + collectionID + ".png";
        string HallBgPath     = root + "/HallBg/" + collectionID + ".png";
        string LoginBgPath    = root + "/LoginBg/" + collectionID + ".png";
        string LogoPath       = root + "/Logos/" + collectionID + ".png";

        string umeng_push_notification_default_large_iconpath
            = root + "/umengpushicon/64/" + +collectionID + ".png";

        string umeng_push_notification_default_small_iconpath
            = root + "/umengpushicon/48/" + +collectionID + ".png";

        Texture2D icon = AssetDatabase.LoadAssetAtPath <Texture2D>(FileUtil.GetProjectRelativePath(iconRoot));

        Texture2D[] androidIcons = new Texture2D[6];
        for (int i = 0; i < androidIcons.Length; i++)
        {
            androidIcons[i] = icon;
        }
        Texture2D[] iosIcons = new Texture2D[18];
        for (int i = 0; i < iosIcons.Length; i++)
        {
            iosIcons[i] = icon;
        }
        Texture2D[] pcIcons = new Texture2D[7];
        for (int i = 0; i < pcIcons.Length; i++)
        {
            pcIcons[i] = icon;
        }
        //AssetDatabase.CopyAsset()
        File.Copy(sharethumbPath, Application.streamingAssetsPath + "/sharethumb.png", true);
        //File.Copy(HallBgPath, AppConst.ABPath + "/Hall/HallScene/HallScencePack@atlas_llpny8.png",true);
        //File.Copy(LoginBgPath, AppConst.ABPath + "/Hall/loadingsceneres/LoadingScenePack@atlas_hl1kcw.png",true);
        File.Copy(LogoPath, AppConst.ABPath + "/Hall/loadingsceneres/LoadingScenePack@atlas_jkp87.png", true);
        File.Copy(umeng_push_notification_default_large_iconpath
                  , Application.dataPath
                  + "/Plugins/Android/res/drawable/umeng_push_notification_default_large_icon.png",
                  true);
        File.Copy(umeng_push_notification_default_small_iconpath
                  , Application.dataPath
                  + "/Plugins/Android/res/drawable/umeng_push_notification_default_small_icon.png",
                  true);
        PlayerSettings.productName = buildInfo.CollectionName;
        PlayerSettings.companyName = "闲游棋牌";
        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Standalone, pcIcons);
        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, androidIcons);
        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.iOS, iosIcons);
        AssetDatabase.Refresh();
    }
Пример #15
0
    public static void BuildForIos(BuildCollectionResInfo buildCfg)
    {
        string assetName = (int)currentCollection + "";

        if (buildCfg.isTrans)
        {
            assetName += "Trans";
        }
        else
        {
            if (Channel == (int)ChannelType.AppStore)
            {
                assetName += "Appstore";
            }
        }
        assetName += ".asset";
        LocalGameCfgData localdata  = Resources.Load <LocalGameCfgData>("gamecfg");
        string           installUrl = localdata.OSSROOT + "/{0}/{1}/{2}/{3}/ios/1.ipa";
        string           verTypeStr = "";

        PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.IL2CPP);
        PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 2);
        if (Channel == (int)ChannelType.AppStore)
        {
            PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, buildCfg.IOSAppStorePackName);
        }
        else
        {
            PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, buildCfg.IOSPackName);
        }
        PlayerSettings.iOS.appInBackgroundBehavior = iOSAppInBackgroundBehavior.Custom;
        PlayerSettings.iOS.backgroundModes         = iOSBackgroundMode.Audio | iOSBackgroundMode.RemoteNotification;


        if (isPublic)
        {
            verTypeStr = "public";
        }
        else
        {
            verTypeStr = "test";
        }

        installUrl = string.Format(installUrl, buildCfg.CollectionID, Channel, verTypeStr, version);

        string txt = File.ReadAllText(Application.dataPath + "/YKFramwork/Editor/AutoBuild/Install.plist");

        txt = txt.Replace("#{url}#", installUrl)
              .Replace("#version#", InstallVersion)
              .Replace("#iconurl#", localdata.OSSROOT + "/" + buildCfg.CollectionID + "/icon.png")
              .Replace("#PackName#", buildCfg.IOSPackName)
              .Replace("#GameName#", buildCfg.CollectionName);

        File.WriteAllText(Application.streamingAssetsPath + "/Install.plist",
                          txt);
        string[] scenes = null;
        if (buildCfg.isTrans)
        {
            scenes = GetTransBuildScenes;
        }
        else
        {
            scenes = GetBuildScenes;
        }

#if UNITY_IOS
        PlayerPrefs.SetString(XcodeProjectUpdater.SETTING_DATA_PATHKEY, "Assets/YKFramwork/Editor/AutoBuild/" + assetName);
        PlayerSettings.iOS.allowHTTPDownload           = true;
        PlayerSettings.iOS.appleEnableAutomaticSigning = false;
        string res = BuildPipeline.BuildPlayer(scenes, outpath, BuildTarget.iOS, BuildOptions.None);
#endif
    }
Пример #16
0
    public static void OnGUI()
    {
        var assets = AssetDatabase.GetAllAssetPaths()
                     .Where(x =>
        {
            return(x.StartsWith("Assets/YKFramwork", StringComparison.InvariantCultureIgnoreCase));
        });

        List <BuildCollectionResInfo> list = new List <BuildCollectionResInfo>();
        List <string> dis = new List <string>();

        foreach (var assetPath in assets)
        {
            BuildCollectionResInfo info = AssetDatabase.LoadAssetAtPath(assetPath, typeof(BuildCollectionResInfo)) as BuildCollectionResInfo;
            if (info != null)
            {
                list.Add(info);
                dis.Add(Path.GetFileNameWithoutExtension(assetPath));
            }
        }
        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Space(5);
            GUIStyle st = new GUIStyle("LargePopup");
            //st.CalcScreenSize(new Vector2(20,200));
            st.margin = new RectOffset(0, 0, 0, 20);
//             st.fixedHeight = 20;
//             st.fixedWidth = 200;
            st.alignment = TextAnchor.MiddleCenter;

            GUIStyle la = new GUIStyle("Label");
            la.margin    = new RectOffset(0, 0, 0, 20);
            la.fontSize  = 20;
            la.alignment = TextAnchor.MiddleLeft;
            GUILayout.Label(new GUIContent("准备生成的配置:"), la);
            selectBuilds = EditorGUILayout.Popup(selectBuilds,
                                                 dis.ToArray(), st);
            //GUI.color = Color.green;
            if (GUILayout.Button("Add", st))
            {
                string path = EditorUtility.SaveFilePanel("保存文件位置", "Assets/YKFramwork/Editor/BuildAbInfo/Collections", "", "asset").Replace("\\", "/");
                path = FileUtil.GetProjectRelativePath(path);
                if (!string.IsNullOrEmpty(path))
                {
                    BuildCollectionResInfo data = ScriptableObject.CreateInstance <BuildCollectionResInfo>();
                    Debug.LogError(path);
                    AssetDatabase.CreateAsset(data, path);
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
            }
            GUILayout.FlexibleSpace();
        }
        EditorGUILayout.EndHorizontal();
        if (list.Count > selectBuilds)
        {
            BuildCollectionResInfo selectinfo = list[selectBuilds];
            if (show == null)
            {
                show = Editor.CreateEditor(selectinfo);
            }
            else
            {
                if (show.target != selectinfo)
                {
                    show = Editor.CreateEditor(selectinfo);
                }
            }
        }
        show.OnInspectorGUI();
    }