示例#1
0
        /// <summary></summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strPath"></param>
        /// <param name="pathType"></param>
        /// <param name="OnError"></param>
        /// <param name="OnSuccess"></param>
        /// <returns></returns>
        public static T LoadRecs <T>(string strPath, RecsPathType pathType, Action <string> OnError, Action <Object> OnSuccess = null) where T : UnityEngine.Object
        {
            if (string.IsNullOrEmpty(strPath))
            {
                return(null);
            }

            switch (RecsAssetBundleMgr.GetRecsSources())
            {
            case RecsSource.FromRecsources:
                //准备路径Resources下
                if (pathType != RecsPathType.ResourcesPath)
                {
                    strPath = FileTool.RecsPathSwitch(strPath, pathType, RecsPathType.ResourcesPath);
                }

                //尝试加载
                T asset = null;
                try
                {
                    asset = Resources.Load <T>(strPath);
                }
                catch (Exception ex)
                {
                    if (OnError != null)
                    {
                        OnError(ex.Message);
                    }
                }

                if (asset != null)
                {
                    OnSuccess(asset);
                }
                return(asset);

            case RecsSource.FormAssetBundleServer:
                break;

            case RecsSource.FormAssetBundleLocal:
                GetIns().StartCoroutine(AssetBundleTool.ILoadAssetBundle(FileTool.RecsPathSwitch(strPath, pathType, RecsPathType.PhysicalFullPath), true, OnError,
                                                                         (AssetBundle a) =>
                {
                    if (OnSuccess != null)
                    {
                        OnSuccess.Invoke(a);
                    }
                }));
                break;

            default:
                break;
            }

            return(null);
        }
示例#2
0
    static void MakeAssetBundleAndroid()
    {
        CSObjectWrapEditor.Generator.ClearAll();
        CSObjectWrapEditor.Generator.GenAll();

        CreateAssetBundles.ClearLuaFiles();
        CreateAssetBundles.CopyLuaFilesToRes();

        AssetBundleGen.NamedAssetBundleName();
        AssetBundleTool.CreateAndroidAssetBundle();
    }
示例#3
0
    private void OnGUIHigh()
    {
        if (GUILayout.Button("清理资源名"))
        {
            AssetBundleTool.ClearAssetBundleName();
        }

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        NeedGenVersion = EditorGUILayout.ToggleLeft("生成版本号", NeedGenVersion);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        NeedRename = EditorGUILayout.ToggleLeft("生成资源包名", NeedRename);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        NeedBuild = EditorGUILayout.ToggleLeft("生成资源包", NeedBuild);
        EditorGUILayout.EndHorizontal();

        if (NeedBuild)
        {
            EditorGUILayout.BeginHorizontal("PopupBackground");
            IsRebuild = EditorGUILayout.ToggleLeft("是否重新完整打包", IsRebuild);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal("PopupBackground");

            BundleOptions = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskField("资源打包设置", BundleOptions, GUILayout.Width(500));
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        NeedGenAssetsList = EditorGUILayout.ToggleLeft("生成资源列表", NeedGenAssetsList);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        IsCopyToStreamPath = EditorGUILayout.ToggleLeft("拷贝AssetBundle到StreamPath", IsCopyToStreamPath);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        NeedGenApp = EditorGUILayout.ToggleLeft("生成APP", NeedGenApp);
        EditorGUILayout.EndHorizontal();

        if (NeedGenApp)
        {
            EditorGUILayout.BeginHorizontal("PopupBackground");
            Options = (BuildOptions)EditorGUILayout.EnumMaskField("生成APP设置", Options, GUILayout.Width(500));
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
    }
示例#4
0
 //文件类型资源
 public AssetInfo(string fullePath, string name, string extension)
 {
     AssetFullPath  = fullePath;
     AssetPath      = "Assets" + fullePath.Replace(Application.dataPath.Replace("/", "\\"), "");
     AssetName      = name;
     GUID           = AssetDatabase.AssetPathToGUID(AssetPath);
     AssetFileType  = AssetBundleTool.GetFileTypeByExtension(extension);
     AssetType      = AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
     IsChecked      = false;
     IsExpanding    = false;
     Bundled        = "";
     childAssetInfo = null;
 }
示例#5
0
    public static List <AssetInfo> _validAssets; //???????
    private void Init()
    {
        if (_validAssets == null)
        {
            _validAssets = new List <AssetInfo>();
        }
        _validAssets.Clear();
        _assetBundle = new AssetBundleInfo();
        _asset       = new AssetInfo(Application.dataPath, "Assets", true);
        AssetBundleTool.ReadAssetsInChildren(_asset);

        Resources.UnloadUnusedAssets();
    }
        public override void Execute(object content)
        {
            base.Execute(content);

            PublishContent publishContent = _content as PublishContent;

            if (publishContent.referenceABSetting)
            {
                AssetBundleTool.BuildDepend();
            }

            Success(publishContent);
        }
示例#7
0
        public override void Execute(object content)
        {
            base.Execute(content);

            publishContent = _content as PublishContent;
            string resPath   = PublishContent.GetResPath(publishContent.GetRootPath());
            string resABPath = PublishContent.GetABPath(resPath);

            //            bool clearResPath = this.publishContent.env == PublishEnvironment.ONLINE;
            bool clearResPath = publishContent.bigVersion;  //不清理res资源

            FileOperateUtil.CreateDirectory(resPath, clearResPath);

            BuildTarget target = publishContent.GetBuildTarget();

            AssetBundleTool.Build(resABPath, target);

            Success(publishContent);
        }
示例#8
0
    private static void BuildAndroidRelease()
    {
        string[] scenes = GetBuildScenes();
        string   path   = GetBuildPathAndroid();

        if (scenes == null || scenes.Length == 0 || path == null)
        {
            return;
        }

        SetupAndroid();

        AssetBundleTool.BuildAssetBundleNormal();
        AssetDatabase.Refresh();

        DefineTool.SetDefineSymbolDevelop();

        BuildPipeline.BuildPlayer(scenes, path, BuildTarget.Android, BuildOptions.None);
    }
示例#9
0
    private void OnGUI()
    {
        versionCode = EditorGUILayout.TextField("打包资源版本号:", versionCode);

        index = EditorGUILayout.Popup(index, options);

        var target = optionsIndex[index];

        if (GUI.Button(new Rect(wndSize.x * 0.25f - 25, wndSize.y * 0.75f, 50, 25), "确定"))
        {
            AssetBundleTool.BuildAllAssetBundles(target);

            BuildAllAssetBundlesConfigList(target);
        }

        if (GUI.Button(new Rect(wndSize.x * 0.5f + 25, wndSize.y * 0.75f, 50, 25), "取消"))
        {
            Close();
        }
    }
示例#10
0
    static void Build(BuildTarget target, string path, BuildOptions opts = BuildOptions.None)
    {
        var watch = new System.Diagnostics.Stopwatch();

        watch.Start();

        ClearAllLuaFiles();
        CopyLuaFilesToRes();

        AssetBundleGen.NamedAssetBundleName();
        AssetBundleTool.CreateAndroidAssetBundle();

        CSObjectWrapEditor.Generator.ClearAll();
        CSObjectWrapEditor.Generator.GenAll();

        // SGK.Database.LoadConfigFromServer();

        // SGK.CharacterConfig.GenerateBattleCharacterConfig();

        /*
         * string UNITY_CACHE_SERVER = System.Environment.GetEnvironmentVariable("UNITY_CACHE_SERVER");
         * if (!string.IsNullOrEmpty(UNITY_CACHE_SERVER)) {
         *  EditorPrefs.SetBool("CacheServerEnabled", false);
         *  EditorPrefs.SetInt("CacheServerMode", 1);
         *  EditorPrefs.SetString("CacheServerIPAddress", UNITY_CACHE_SERVER);
         * }
         */

        string ANDROID_HOME = System.Environment.GetEnvironmentVariable("ANDROID_HOME");

        if (!string.IsNullOrEmpty(ANDROID_HOME))
        {
            EditorPrefs.SetString("AndroidSdkRoot", System.Environment.GetEnvironmentVariable("ANDROID_HOME"));
        }

        BuildPipeline.BuildPlayer(scenes, path, target, opts);
        watch.Stop();
        UnityEngine.Debug.Log(string.Format("build package dela time {0}ms, {1}s, {2}min", watch.ElapsedMilliseconds, watch.ElapsedMilliseconds / 1000, watch.ElapsedMilliseconds / 1000 / 60));
    }
示例#11
0
 public static void BuildStep2()
 {
     AssetBundleTool.CreateAndroidAssetBundle();
 }
示例#12
0
 private void Build()
 {
     AssetBundleTool.Build(mExportPath, mTarget, true);
 }
示例#13
0
    private void TitleGUI()
    {
        if (GUI.Button(new Rect(5, 5, 60, 15), "Create", _preButton))
        {
            AssetBundleBuildInfo build = new AssetBundleBuildInfo("ab" + System.DateTime.Now.ToString("yyyyMMddHHmmss"));
            _assetBundle.AssetBundles.Add(build);
        }
        //当前未选中任何一个AB包的话  禁用之后的所有UI控件
        GUI.enabled = _currentAB == -1 ? false : true;
        //重命名当前选中的AB包(必须选中任意一个AB包后方可生效);
        if (GUI.Button(new Rect(65, 5, 60, 15), "Rename", _preButton))
        {
            _isRename    = true;
            _renameValue = "";
        }
        //清空当前选中的AB包中的所有资源(必须选中任意一个AB包后方可生效);
        if (GUI.Button(new Rect(125, 5, 60, 15), "Clear", _preButton))
        {
            if (EditorUtility.DisplayDialog("Prompt", "Clear" + _assetBundle.AssetBundles[_currentAB].Name + " ?", "Yes", "No"))
            {
                _assetBundle.AssetBundles[_currentAB].CleareAsset();
            }
        }
        //删除当前的AB包,同时会自动执行Clear操作(必须选中任意一个AB包后方可生效);
        if (GUI.Button(new Rect(185, 5, 60, 15), "Delete", _preButton))
        {
            if (EditorUtility.DisplayDialog("Prompt", "Delete" + _assetBundle.AssetBundles[_currentAB].Name + " ?", "Yes", "No"))
            {
                _assetBundle.DeleteAssetBundle(_currentAB);
                _currentAB = -1;
            }
        }
        //被勾选的资源添加到当前选中的AB包(必须选中任意一个AB包后方可生效);
        if (GUI.Button(new Rect(250, 5, 100, 15), "Add Assets", _preButton))
        {
            List <AssetInfo> assets = _validAssets.GetCheckedAssets();
            for (int i = 0; i < assets.Count; i++)
            {
                _assetBundle.AssetBundles[_currentAB].AddAsset(assets[i]);
            }
        }
        GUI.enabled = true;

        // _hideInvalidAsset =;
        _hideBundleAsset = GUI.Toggle(new Rect(460, 5, 100, 15), _hideBundleAsset, "Hide Bundled");
        if (GUI.Toggle(new Rect(360, 5, 100, 15), _hideInvalidAsset, "Hide Invalid") != _hideInvalidAsset)
        {
            _hideInvalidAsset = !_hideInvalidAsset;
        }

        if (GUI.Button(new Rect(250, 25, 60, 15), "Open", _preButton))
        {
            if (_buildPath != "")
            {
                Application.OpenURL(_buildPath);
            }
        }
        if (GUI.Button(new Rect(310, 25, 60, 15), "Browse", _preButton))
        {
            _buildPath = EditorUtility.OpenFolderPanel("BuildPath", string.Empty, string.Empty);
            EditorPrefs.SetString("BuildPath", _buildPath);
        }
        if (_buildPath == "")
        {
            _buildPath = EditorPrefs.GetString("BuildPath", "");
        }
        GUI.Label(new Rect(370, 25, 70, 15), "Build Path:");
        _buildPath = GUI.TextField(new Rect(440, 25, 300, 15), _buildPath);

        BuildTarget buildTarget = (BuildTarget)EditorGUI.EnumPopup(new Rect((int)position.width - 205, 5, 150, 15), _buildTarget, _preDropDown);

        if (GUI.Button(new Rect((int)position.width - 55, 5, 50, 15), "Build", _preButton))
        {
            AssetBundleTool.BuildAssetBundles();
        }
    }
    //绘制窗口时调用
    void OnGUI()
    {
        scroll_pos = EditorGUILayout.BeginScrollView(scroll_pos);
        //输入框控件
        GUILayout.Space(10);
        setting.appName = EditorGUILayout.TextField("项目名称:", setting.appName);
        GUILayout.Space(5);
        keystoreCnf.bundleIdentifier = EditorGUILayout.TextField("项目包名:", keystoreCnf.bundleIdentifier);
        GUILayout.Space(5);
        setting.version = EditorGUILayout.TextField("版本号:", setting.version);
        GUILayout.Space(5);
        setting.serverHost = EditorGUILayout.TextField("服务器地址:", setting.serverHost);
        GUILayout.Space(5);
        setting.resouceHost = EditorGUILayout.TextField("热更资源地址:", setting.resouceHost);
        GUILayout.Space(5);
        setting.umengAndroidKey = EditorGUILayout.TextField("友盟Android key:", setting.umengAndroidKey);
        GUILayout.Space(5);
        setting.umengIOSKey = EditorGUILayout.TextField("友盟iOS key:", setting.umengIOSKey);
        GUILayout.Space(5);
        setting.quickProductCode = EditorGUILayout.TextField("Quick ProductCode:", setting.quickProductCode);
        GUILayout.Space(5);
        setting.selfChannelID = EditorGUILayout.TextField("默认渠道ID:", setting.selfChannelID);
        GUILayout.Space(5);
        //setting.weChatAppId = EditorGUILayout.TextField("WeChatAppId:", setting.weChatAppId);
        //GUILayout.Space(5);
        //setting.weChatSecret = EditorGUILayout.TextField("WeChatSecret:", setting.weChatSecret);
        //GUILayout.Space(5);
        setting.isDevMode = EditorGUILayout.Toggle("测试模式", setting.isDevMode);
        GUILayout.Space(5);
        setting.isChannel = EditorGUILayout.Toggle("渠道包", setting.isChannel);
        GUILayout.Space(5);

        GUILayout.BeginHorizontal();
        GUILayout.Label("登录方式:", GUILayout.Width(146));
        setting.touristLogin = EditorGUILayout.Toggle("游客登录", setting.touristLogin, GUILayout.Width(220));
        GUILayout.Space(5);
        setting.channelLogin = EditorGUILayout.Toggle("渠道登录", setting.channelLogin, GUILayout.Width(220));
        GUILayout.Space(5);
        setting.weChatLogin = EditorGUILayout.Toggle("微信登录", setting.weChatLogin, GUILayout.Width(220));
        GUILayout.Space(5);
        GUILayout.EndHorizontal();
        GUILayout.Space(5);
        GUILayout.BeginHorizontal();
        GUILayout.Space(5);
        GUILayout.Label("keystore", GUILayout.Width(146), GUILayout.Height(18f));
        GUILayout.Label(keystoreCnf.keystore, "HelpBox", GUILayout.Height(18f));
        if (GUILayout.Button(new GUIContent("浏览", "浏览文件夹")))
        {
            string path = EditorUtility.OpenFilePanel("keystore", keystoreCnf.keystore, "keystore");
            keystoreCnf.keystore = path.Replace(System.Environment.CurrentDirectory.Replace("\\", "/"), ".");
            SaveSetting();
            SaveKeystoreSetting();
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(5);

        keystoreCnf.keypass = EditorGUILayout.TextField("keypass:"******"keyaliname:", keystoreCnf.keyaliname);
        GUILayout.Space(5);
        keystoreCnf.keyalipass = EditorGUILayout.TextField("keyalipass:"******"git报告提交ID:", gitCommitID);
        GUILayout.Space(5);

        PlayerSettings.productName = setting.appName;
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android | BuildTargetGroup.iOS | BuildTargetGroup.Standalone, keystoreCnf.bundleIdentifier);
        PlayerSettings.bundleVersion        = setting.version;
        PlayerSettings.Android.keystoreName = keystoreCnf.keystore;
        PlayerSettings.Android.keystorePass = keystoreCnf.keypass;
        PlayerSettings.Android.keyaliasName = keystoreCnf.keyaliname;
        PlayerSettings.Android.keyaliasPass = keystoreCnf.keyalipass;

        GUILayout.Space(5);

        //if (GUILayout.Button("清理C#Warp代码"))
        //{
        //    AssetDatabase.Refresh();
        //}

        //if (GUILayout.Button("生成C#Warp代码"))
        //{
        //    if (EditorApplication.isCompiling)
        //    {
        //        EditorUtility.DisplayDialog("提示", "请等待编译完成后执行!", "OK");
        //    }
        //    else
        //    {
        //        //Generator.GenAll();
        //    }
        //}

        if (GUILayout.Button("一键打AssetBundle"))
        {
            AssetBundleTool.QuickBuildAssetBundle();
            SaveSetting();
        }

        if (GUILayout.Button("快速构建(不打ab)"))
        {
            SaveSetting();
            Build();
        }

        if (GUILayout.Button("导出Gradle工程"))
        {
            SaveSetting();
            ExportGradle();
        }
        if (GUILayout.Button("SaveSetting"))
        {
            SaveSetting();
        }
        EditorGUILayout.EndScrollView();
    }
示例#15
0
 static public void OfflineData()
 {
     //BuildPipeline.BuildAssetBundles
     AssetBundleTool.Start();
     Debug.Log("scuessed!");
 }
示例#16
0
    private void Gen()
    {
        bool needRename        = NeedRename || !IsHighMode;
        bool needBuild         = NeedBuild || !IsHighMode;
        bool needGenAssetsList = NeedGenAssetsList || !IsHighMode;
        bool needGenVersion    = NeedGenVersion || !IsHighMode;
        bool needGenApp        = NeedGenApp || !IsHighMode;

        bool isRebuild          = IsRebuild || !IsHighMode;
        bool isCopyToStreamPath = IsCopyToStreamPath || !IsHighMode;

        BuildOptions            buildOptions  = BuildOptions.None;
        BuildAssetBundleOptions bundleOptions = BuildAssetBundleOptions.ChunkBasedCompression | BuildAssetBundleOptions.StrictMode | BuildAssetBundleOptions.DeterministicAssetBundle;

        if (IsHighMode)
        {
            buildOptions  = Options;
            bundleOptions = BundleOptions;
        }

        if (needGenApp && string.IsNullOrEmpty(AppOutPath))
        {
            AppOutPath = EditorUtility.OpenFolderPanel("请选择目录", AppOutPath, AppOutPath);
            if (string.IsNullOrEmpty(AppOutPath))
            {
                return;
            }
        }

        if (needGenVersion)
        {
            if (EditorUtility.DisplayCancelableProgressBar("生成新版本号", "不着急", 0))
            {
                EditorUtility.ClearProgressBar();
                return;
            }

            AssetBundleTool.GenVersion(Target, currentVersion, "develop");

            if (EditorUtility.DisplayCancelableProgressBar("生成新版本号", "不着急", 1))
            {
                EditorUtility.ClearProgressBar();
                return;
            }
        }

        if (needRename)
        {
            if (EditorUtility.DisplayCancelableProgressBar("命名资源文件", "不着急", 0))
            {
                EditorUtility.ClearProgressBar();
                return;
            }

            AssetBundleTool.ClearAssetBundleName();
            AssetBundleTool.GenAssetBundleName();
            if (EditorUtility.DisplayCancelableProgressBar("命名资源文件", "不着急", 1))
            {
                EditorUtility.ClearProgressBar();
                return;
            }
        }

        if (needBuild)
        {
            if (EditorUtility.DisplayCancelableProgressBar("生成AB包", "不着急", 0))
            {
                EditorUtility.ClearProgressBar();
                return;
            }

            AssetBundleTool.BuildBundle(isRebuild, Target, bundleOptions);
            AssetBundleTool.ClearAssetBundleName();

            if (EditorUtility.DisplayCancelableProgressBar("生成AB包", "不着急", 1))
            {
                EditorUtility.ClearProgressBar();
                return;
            }
        }

        if (needGenAssetsList)
        {
            if (EditorUtility.DisplayCancelableProgressBar("生成资源列表", "不着急", 0))
            {
                EditorUtility.ClearProgressBar();
                return;
            }

            AssetBundleTool.GenAssetsList(Target);

            if (EditorUtility.DisplayCancelableProgressBar("生成资源列表", "不着急", 1))
            {
                EditorUtility.ClearProgressBar();
                return;
            }
        }

        if (isCopyToStreamPath)
        {
            if (EditorUtility.DisplayCancelableProgressBar("拷贝AssetBundle", "不着急", 0))
            {
                EditorUtility.ClearProgressBar();
                return;
            }
            AssetBundleTool.CopyAssetBundleToStream(Target);
            if (EditorUtility.DisplayCancelableProgressBar("拷贝AssetBundle", "不着急", 1))
            {
                EditorUtility.ClearProgressBar();
                return;
            }
        }

        if (needGenApp)
        {
            if (EditorUtility.DisplayCancelableProgressBar("生成APP", "不着急", 0))
            {
                EditorUtility.ClearProgressBar();
                return;
            }

            string appFilePath = null;
            if (UseVersionSuffix)
            {
                switch (Target)
                {
                case BuildTarget.StandaloneWindows:
                case BuildTarget.StandaloneWindows64:
                    appFilePath = string.Format("{0}/football_{1}.exe", AppOutPath, currentVersion);
                    break;

                case BuildTarget.iOS:
                    appFilePath = string.Format("{0}/football_{1}.ipa", AppOutPath, currentVersion);
                    break;

                case BuildTarget.Android:
                    appFilePath = string.Format("{0}/football_{1}.apk", AppOutPath, currentVersion);
                    break;

                default:
                {
                    EditorUtility.ClearProgressBar();
                    return;
                }
                }
            }
            else
            {
                switch (Target)
                {
                case BuildTarget.StandaloneWindows:
                    appFilePath = string.Format("{0}/football.exe", AppOutPath);
                    break;

                case BuildTarget.iOS:
                    appFilePath = string.Format("{0}/football.ipa", AppOutPath);
                    break;

                case BuildTarget.Android:
                    appFilePath = string.Format("{0}/football.apk", AppOutPath);
                    break;

                default:
                {
                    EditorUtility.ClearProgressBar();
                    return;
                }
                }
            }

            if (appFilePath != null)
            {
#if UNITY_ANDROID
                PlayerSettings.Android.keystoreName = Application.dataPath + "/../football.keystore";
                PlayerSettings.Android.keystorePass = "******";
                PlayerSettings.Android.keyaliasName = "斗球学园";
                PlayerSettings.Android.keyaliasPass = "******";
#endif

                BuildPipeline.BuildPlayer(AssetBundleTool.GetBuildScenes(), appFilePath, Target, buildOptions);
            }
        }

        EditorUtility.ClearProgressBar();
    }