示例#1
0
 private void GenerateAsset(List <string> modList, string outputDir)
 {
     if (modList.IsEmpty())
     {
         return;
     }
     foreach (string assetPath in modList)
     {
         string dstPath = GetOutputPath(outputDir, assetPath);
         dstPath = PathUtil.ReplaceExtension(dstPath, FileTypeEx.ASSET_BUNDLE);
         Object obj = AssetDatabase.LoadAssetAtPath("Assets/" + assetPath, typeof(Object));
         if (obj != null)
         {
             AssetBundleBuilder.BuildAssetBundle(dstPath, buildTarget, obj, Path.GetFileNameWithoutExtension(assetPath));
             log.Debug("Create AssetBundle '{0}'", dstPath);
         }
         else
         {
             throw new Exception("Invalid asset " + assetPath);
         }
     }
 }
示例#2
0
    public void OnGUIMenu(int window)
    {
        menuscrollPosition = EditorGUILayout.BeginScrollView(menuscrollPosition);
        EditorGUILayout.LabelField("Build Target", CreateGUIStyle(11, new Color(0.8f, 0.8f, 0.8f, 1.0f), FontStyle.Bold));
        EditorGUILayout.LabelField(EditorUserBuildSettings.activeBuildTarget.ToString());
        EditorGUILayout.LabelField("Output Path", CreateGUIStyle(11, new Color(0.8f, 0.8f, 0.8f, 1.0f), FontStyle.Bold));

        GUI.enabled = false;
        EditorGUILayout.TextField(AssetBundleBuildSetting.RelativeOutputPath);
        GUI.enabled = true;
        if (GUILayout.Button("Find"))
        {
            string result = EditorUtility.OpenFolderPanel("Select Output Path", AssetBundleBuildSetting.RelativeOutputPath, "");
            if (!string.IsNullOrEmpty(result))
            {
                string relativePath = EnvUtil.MakeRelative(result, System.Environment.CurrentDirectory);
                AssetBundleBuildSetting.RelativeOutputPath = relativePath;
                CachedFileInfo();
            }
        }

        EditorGUILayout.Separator();
        GUI.color = Color.green;
        if (GUILayout.Button("Build"))
        {
            CachedFileInfo();
            List <string> changedList = AssetBundleBuilder.BuildAssetBundle(EditorUserBuildSettings.activeBuildTarget, AssetBundleBuildSetting.AbsoluteOutputPath);
            foreach (var c in changedList)
            {
                var ret = this.assetBundleList.Find(o => o.AssetBundleName.Equals(c));
                if (ret != null)
                {
                    ret.IsChanged = true;
                }
                else
                {
                    var path     = AssetBundleBuilder.GetAssetBundlePath(EditorUserBuildSettings.activeBuildTarget, AssetBundleBuildSetting.AbsoluteOutputPath);
                    var fileInfo = new System.IO.FileInfo(path);
                    this.assetBundleList.Add(new AssetBundleBuildInfo(fileInfo, EditorUserBuildSettings.activeBuildTarget, AssetBundleBuildSetting.AbsoluteOutputPath));
                }
            }
        }
        GUI.color = Color.white;
        EditorGUILayout.LabelField("PublishSetting", CreateGUIStyle(11, new Color(0.8f, 0.8f, 0.8f, 1.0f), FontStyle.Bold));
        AssetBundleBuildSetting.PublishState = (AssetBundleBuildSetting.PublishStateEnum)EditorGUILayout.EnumPopup(AssetBundleBuildSetting.PublishState);
        if (AssetBundleBuildSetting.PublishState == AssetBundleBuildSetting.PublishStateEnum.ShellScript)
        {
            EditorGUILayout.LabelField("Shellscript");
            AssetBundleBuildSetting.ShellScript = EditorGUILayout.TextArea(AssetBundleBuildSetting.ShellScript, GUILayout.Height(100));
            EditorGUILayout.HelpBox("AssetBundle OutputPath is set in EnvironmentVariables 'AssetBundlePath' " + System.Environment.NewLine + " ex) $AssetBundlePath  ,%AssetBundlePath%", MessageType.Info);
        }
        GUI.color = Color.green;
        if (GUILayout.Button("Publish"))
        {
            foreach (var assetBundle in this.assetBundleList)
            {
                if (!assetBundle.IsInAssetDataBase)
                {
                    assetBundle.DeleteFile();
                }
            }

            if (AssetBundleBuildSetting.PublishState == AssetBundleBuildSetting.PublishStateEnum.ShellScript)
            {
                PublishToShellScript();
            }
            else if (AssetBundleBuildSetting.PublishState == AssetBundleBuildSetting.PublishStateEnum.Streaming)
            {
                PublishToStreaming();
            }
            CachedFileInfo();
        }
        GUI.color = Color.white;
        EditorGUILayout.EndScrollView();
    }
 static void BuildAndroidAssetBundle()
 {
     AssetBundleBuildSetting.RelativeOutputPath = EnvUtil.GetEnvValue(ENV_ASSETBUNDLE_OUTPUT, AssetBundleBuildSetting.RelativeOutputPath);
     AssetBundleBuilder.BuildAssetBundle(BuildTarget.Android, AssetBundleBuildSetting.RelativeOutputPath);
 }