Ejemplo n.º 1
0
    public static void CopyAssetBundlesAudioToStreamingAssetsAudio(BuildTarget buildTarget, string channelName)
    {
        string pltname = GetPlatformName(buildTarget);

        string sourcePath = GetAudioOutputPath(buildTarget, channelName);
        //string sourcePath = Path.Combine(source, pltname);

        string destination = AssetBundleUtility.GetStreamingAssetsAudioDataPath();
        string destPath    = Path.Combine(destination, pltname);

        GameUtility.CheckDirAndCreateWhenNeeded(destPath);
        GameUtility.SafeDeleteDir(destPath);
        //清理目录
        CopyFolder(sourcePath, destPath, ".meta");
        string soundbakSrcpath = Path.Combine(sourcePath, AssetBundleConfig.WWISESoundbanksInfo);
        string soundbakDstpath = Path.Combine(Application.dataPath, AssetBundleConfig.WWISESoundbanksInfoPath);

        try
        {
            GameUtility.SafeDeleteFile(soundbakDstpath);
            FileUtil.CopyFileOrDirectoryFollowSymlinks(soundbakSrcpath, soundbakDstpath);
        }
        catch (System.Exception ex)
        {
            Debug.LogError("CopyAssetBundlesAudioToStreamingAssetsAudio, err : " + ex);
            return;
        }
        Debug.Log("CopyAssetBundlesAudioToStreamingAssetsAudio success");

        AssetDatabase.Refresh();
    }
Ejemplo n.º 2
0
    public static string GetAssetBundleOutputPath(BuildTarget target, string channelName)
    {
        string outputPath = Path.Combine(AssetBundleConfig.AssetBundlesBuildOutputPath, GetAssetBundleRelativePath(target, channelName));

        GameUtility.CheckDirAndCreateWhenNeeded(outputPath);
        return(outputPath);
    }
Ejemplo n.º 3
0
    static void CopyAudio()
    {
        string source = Path.Combine(Application.dataPath, AssetBundleConfig.WWISEAssetBundlAudioPath);

        source = Path.Combine(source, "Windows");
        string destination = Path.Combine(Application.dataPath, "StreamingAssets");

        destination = Path.Combine(destination, AssetBundleConfig.AssetBundlesFolderName);
        destination = Path.Combine(destination, AssetBundleConfig.AssetBundlesAudioFolderName_GEN);
        GameUtility.CheckDirAndCreateWhenNeeded(destination);
        destination = Path.Combine(destination, "Windows");
        GameUtility.SafeDeleteDir(destination);
        try
        {
            FileUtil.CopyFileOrDirectoryFollowSymlinks(source, destination);
            var allManifest = GameUtility.GetSpecifyFilesInFolder(destination, new string[] { ".meta" });
            if (allManifest != null && allManifest.Length > 0)
            {
                for (int i = 0; i < allManifest.Length; i++)
                {
                    GameUtility.SafeDeleteFile(allManifest[i]);
                }
            }
        }
        catch (System.Exception ex)
        {
            Debug.LogError("Something wrong, you need manual delete folder in StreamingAssets, err : " + ex);
            return;
        }
        Debug.Log("Audio Copy Finished");
        AssetDatabase.Refresh();
    }
Ejemplo n.º 4
0
    public static void BuildXCode(string channelName, bool isTest)
    {
        BuildTarget buildTarget = BuildTarget.iOS;

        PackageUtils.CopyAssetBundlesToStreamingAssets(buildTarget, channelName);
        LaunchAssetBundleServer.WriteAssetBundleServerURL(channelName);

        string buildFolder = Path.Combine(System.Environment.CurrentDirectory, XCodeOutputPath);

        buildFolder = Path.Combine(buildFolder, channelName);
        GameUtility.CheckDirAndCreateWhenNeeded(buildFolder);

        string iconPath = "Assets/Editor/icon/ios/{0}/{1}.png";

        string[]         iconSizes = new string[] { "180", "167", "152", "144", "120", "114", "76", "72", "57" };
        List <Texture2D> iconList  = new List <Texture2D>();

        for (int i = 0; i < iconSizes.Length; i++)
        {
            Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(string.Format(iconPath, channelName, iconSizes[i]), typeof(Texture2D));
            iconList.Add(texture);
        }
        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.iOS, iconList.ToArray());

        BaseChannel channel = ChannelManager.instance.CreateChannel(channelName);

        PlayerSettings.applicationIdentifier = channel.GetBundleID();
        PlayerSettings.productName           = channel.GetPackageName();
        PackageUtils.CheckAndAddSymbolIfNeeded(buildTarget, channelName);
        BuildPipeline.BuildPlayer(GetBuildScenes(), buildFolder, buildTarget, BuildOptions.None);
    }
Ejemplo n.º 5
0
    public static void BuildAndroid(string channelName)
    {
        BuildTarget buildTarget = BuildTarget.Android;

        PackageUtils.CopyAssetBundlesToStreamingAssets(buildTarget, channelName);
        BaseChannel channel = ChannelManager.instance.CreateChannel(channelName);

        if (channel.HasAndroidSDK())
        {
            CopyAndroidSDKResources(channelName);
        }
        LaunchAssetBundleServer.WriteAssetBundleServerURL(channelName);

        string buildFolder = Path.Combine(System.Environment.CurrentDirectory, ApkOutputPath);

        GameUtility.CheckDirAndCreateWhenNeeded(buildFolder);
        PlayerSettings.applicationIdentifier = channel.GetBundleID();
        PlayerSettings.productName           = channel.GetPackageName();

        string savePath = null;

        if (channel.IsGooglePlay())
        {
            savePath = Path.Combine(buildFolder, channelName);
            GameUtility.SafeDeleteDir(savePath);
            BuildPipeline.BuildPlayer(GetBuildScenes(), savePath, buildTarget, BuildOptions.AcceptExternalModificationsToPlayer);
        }
        else
        {
            savePath = Path.Combine(buildFolder, channel.GetPackageName() + "_" + channelName + "_" + PlayerSettings.bundleVersion + ".apk");
            BuildPipeline.BuildPlayer(GetBuildScenes(), savePath, buildTarget, BuildOptions.None);
        }
        Debug.Log(string.Format("Build android player for : {0} done! output :{1}", channelName, savePath));
    }
Ejemplo n.º 6
0
    private static void CreateAssetBundleDispatcher(string assetName, bool childrendType)
    {
        //Logger.LogError("====================" + assetName);
        string databaseAssetPath = Path.Combine("Assets", "Editor", "Addressable", "Database", Assets_Package, assetName + ".asset");
        var    dir = Path.GetDirectoryName(databaseAssetPath);

        GameUtility.CheckDirAndCreateWhenNeeded(dir);

        var instance = ScriptableObject.CreateInstance <AddressableDispatcherConfig>();

        AssetDatabase.CreateAsset(instance, databaseAssetPath);
        AssetDatabase.Refresh();


        instance.PackagePath = assetName;

        if (childrendType)
        {
            instance.Type = AddressableDispatcherFilterType.Children;
        }
        else
        {
            instance.Type = AddressableDispatcherFilterType.Root;
        }

        instance.Apply();
        EditorUtility.SetDirty(instance);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
Ejemplo n.º 7
0
        public static string GetBuildPlatformOutputPath(BuildTarget target)
        {
            string outputPath = Path.Combine(AssetBundleConfig.AssetBundlesBuildOutputPath, GetPlatformName(target));

            GameUtility.CheckDirAndCreateWhenNeeded(outputPath);
            return(outputPath);
        }
Ejemplo n.º 8
0
    public string LocalImage(string url)
    {
        byte[] input = Encoding.Default.GetBytes(url.Trim());
        System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] output         = md5.ComputeHash(input);
        string md5_url_string = BitConverter.ToString(output).Replace("-", "");
        string path           = Application.persistentDataPath + "/downloadimage/";

        GameUtility.CheckDirAndCreateWhenNeeded(path);
        bool   isFile   = new Uri(url).IsFile; //判断url是否本地路径。 本地文件直接读取,不复制到应用目录
        string savePath = Application.persistentDataPath + "/downloadimage/" + md5_url_string + ".png";

        //Debug.LogError("=======savePath:" + savePath);
        return(savePath);
    }
        void DrawCreateAssetBundleDispatcher()
        {
            if (GUILayout.Button("Create AssetBundle Dispatcher"))
            {
                var dir = Path.GetDirectoryName(databaseAssetPath);
                GameUtility.CheckDirAndCreateWhenNeeded(dir);

                var instance = CreateInstance <AssetBundleDispatcherConfig>();
                AssetDatabase.CreateAsset(instance, databaseAssetPath);
                AssetDatabase.Refresh();

                Initialize();
                Repaint();
            }
        }
        static int _m_CheckDirAndCreateWhenNeeded_xlua_st_(RealStatePtr L)
        {
            try {
                {
                    string _folderPath = LuaAPI.lua_tostring(L, 1);

                    GameUtility.CheckDirAndCreateWhenNeeded(_folderPath);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Ejemplo n.º 11
0
 public static bool CopyFolder(string src, string dst, string filter)
 {
     if (!Directory.Exists(src))
     {
         Debug.LogError("folder " + src + " :is not exist");
         return(false);
     }
     if (!Directory.Exists(dst))
     {
         //逐级创建
         GameUtility.CheckDirAndCreateWhenNeeded(dst);
         //删除最终
         GameUtility.SafeDeleteDir(dst);
     }
     else
     {
         GameUtility.SafeDeleteDir(dst);
     }
     //检测目标路路径是否存在
     Debug.Log("CopyFolder src Path:" + src);
     Debug.Log("CopyFolder dst Path:" + dst);
     try
     {
         FileUtil.CopyFileOrDirectory(src, dst);
         if (filter.Length > 0)
         {
             var allfiles = GameUtility.GetSpecifyFilesInFolder(dst);
             if (allfiles != null && allfiles.Length > 0)
             {
                 for (int i = 0; i < allfiles.Length; i++)
                 {
                     if (allfiles[i].IndexOf(filter) >= 0)
                     {
                         GameUtility.SafeDeleteFile(allfiles[i]);
                     }
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         Debug.LogError("Copy folder err : " + ex);
         return(false);
     }
     return(true);
 }