I need help copying files that are inside Unity’s folder to where our executable is being created. I went online and found exactly what I was looking for but when I go ahead and implement it, the files are not being copied correctly. Here is what I have:
using UnityEngine;
using UnityEditor;
using System.Diagnostics;
public class UnityEditorClass {
[MenuItem("MyTools/Windows Build With Postprocess")]
public static void BuildGame()
{
// Get filename.
string path = EditorUtility.SaveFolderPanel("../Desktop/", "", ""); //The executable (for now) is created in the desktop
// Copy a file from the project folder to the build folder, alongside the built game.
FileUtil.CopyFileOrDirectory("C:/SchoolProjects/GSP2190/FirstGame", path + "vector2.dll");
FileUtil.CopyFileOrDirectory("C:/SchoolProjects/GSP2190/FirstGame", path + "mathHelper.dll");
// Run the game (Process class from System.Diagnostics).
Process proc = new Process();
proc.StartInfo.FileName = path + "Test.exe";
proc.Start();
}
}
And yes, this script is stashed within the Editor folder.
My questions are:
- Is the file name path correct
- Am I copying the files correctly?
- How come my files are not being copied correctly?
Thank you so much in advance!