小编use*_*211的帖子

在运行时加载 MP3 文件

我正在尝试使用在运行时加载 mp3 文件WWW我正在尝试使用 Unity 中提供的类

我没有收到任何错误,但在处理歌曲后我无法播放音乐。我到处都找过了,但找不到任何可以帮助我的东西。

这是我当前使用的代码:

public class OpenFile : MonoBehaviour {
    string path;
    string extension;
    public GameObject musicAnalysis;
    string songName;
    float length;
    AudioSource song;

    // Use this for initialization
    void Start () {
        song =  musicAnalysis.GetComponent<AudioSource>();
    }

    // Update is called once per frame
    void Update () {
        if(song.isPlaying != true){
            song.Play();
        }
    }

    public void FileSelect(){
        //Open windows Exploer 
        path = EditorUtility.OpenFilePanel("Select a Song","","");

        print(path);

        //Take the end of the the path and sasve it …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

4
推荐指数
1
解决办法
3万
查看次数

如果文件存在,请覆盖它?

我正在创建一个备份文件的应用程序,我需要检查文件是否存在,如果是,则覆盖它.

这是我到目前为止:

private void Copy(string sourceDir, string targetDir)
{
    Directory.CreateDirectory(targetDir);

    foreach (var file in Directory.GetFiles(sourceDir))
    {
        File.Copy(file, Path.Combine(targetDir, Path.GetFileName(file)));
        logWindow.AppendText("\nCopying file" + file + "Complete");
    }

    foreach (var directory in Directory.GetDirectories(sourceDir))
    {    
        Copy(directory, Path.Combine(targetDir, Path.GetFileName(directory)));
        logWindow.AppendText("\n" + directory);
    }
Run Code Online (Sandbox Code Playgroud)

c# file

1
推荐指数
1
解决办法
3799
查看次数

字符串到文本框

我创建了一个方法,允许我找到下一个空Box:

public int CheckBox(int boxNum) {
        int BoxNumber = 0;

        TextBox[] itemBoxArray = new TextBox[] { itemBox0, itemBox1, itemBox2, itemBox3, itemBox4, itemBox5, itemBox6, itemBox7,
            itemBox8, itemBox9,itemBox10,itemBox11,itemBox12,itemBox13,itemBox14,itemBox15,};
        for (int i = 0; i < itemBoxArray.Length; i++)
        {
            if (String.IsNullOrEmpty(itemBoxArray[i].Text))
            {
                BoxNumber = i;
                i = 15;                    
            }
        }
        return BoxNumber;
    }
Run Code Online (Sandbox Code Playgroud)

接下来我创建了一个按钮来检查空盒子是什么,我想在这个盒子里输入一些内容,但是我找不到将转换带有空盒号的字符串转换为该文本框的方法:

    private void StandAroundRebar_Click(object sender, EventArgs e)
    {
        int emptybox = CheckBox(0);
        string emptyboxString = emptybox.ToString();

        string newbox = "itemBox" + emptyboxString;

        MessageBox.Show("TextBox # " + newbox + " is …
Run Code Online (Sandbox Code Playgroud)

c# textbox

0
推荐指数
1
解决办法
97
查看次数

标签 统计

c# ×3

file ×1

textbox ×1

unity-game-engine ×1