Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mmangual_83 · Jan 14, 2014 at 02:26 PM · c#editorunityeditoreditor-scripting

Working with Unity Editor

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:

  1. Is the file name path correct

  2. Am I copying the files correctly?

  3. How come my files are not being copied correctly?

Thank you so much in advance!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HappyMoo · Jan 14, 2014 at 02:40 PM

Pleas lookup EditorUtility.SaveFolderPanel - The first parameter is supposed to be the title of the dialog, not the folder. If you're not sure, try to Debug.Log() stuff out.

And only you can tell if the paths are right, but it looks like you are trying to copy the folder "JAI" onto a file... that doesn't work.

You probably mean: FileUtil.CopyFileOrDirectory("C:/Projects/SBIR/sbir-phaseii/JAI/agility_input_win32.dll", path + "agility_input_win32.dll");

if the path includes a / at the end already.

Other than that, you need to know if these are the right files and if Test.exe really exists at the destination

Comment
Add comment · Show 19 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mmangual_83 · Jan 14, 2014 at 02:42 PM 0
Share

Test.exe doesn't technically exists, not until I hit the build button and name my executable Test.exe

avatar image mmangual_83 · Jan 14, 2014 at 02:50 PM 0
Share

Thank you for the reply but it still does not copy the files over. The EditorUtility.SaveFolderPanel says that the first parameter should be where the game is built according to this page:

link text

avatar image HappyMoo · Jan 14, 2014 at 03:03 PM 0
Share

The script you mention also calls BuildPipeline.BuildPlayer to actually build the game...

You didn't mention you want to build the game - I assumed the Game is already built. The function EditorUtility.SaveFolderPanel just asks you for a folder, if you want to do more, you need to script more.

avatar image mmangual_83 · Jan 14, 2014 at 03:14 PM 0
Share

The only thing I want is just to copy the dlls over. The reason as to why I didnt add the build game is because I figured I didnt need it since I have to go to build settings and create the executable there.

avatar image HappyMoo · Jan 14, 2014 at 03:34 PM 0
Share

Please Debug.Log(path) and check if all paths and files are there. Investigate.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Custom Unity Editor Issue 1 Answer

Equivalent of OpenFilePanel without using UnityEditor? 5 Answers

Is it possible for me to add new objects in the thing that comes up when you right click in the heirarchy? 1 Answer

Bind to OnWillSaveAssets and force to save my scene 0 Answers

Updating object on inspector value changes in editor 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges