Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
5
Question by davedev · Mar 13, 2010 at 09:06 PM · application

How do I get the Application Path?

I know I can get the application data path, but is it possible to get just the application path? I want to have a config file next to the executable file/icon on mac and windows and not in a folder

So I want player.exe config.dat

and for mac

Player (package) config.dat

Comment
Add comment · Show 1
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 Emmy16 · Feb 03, 2016 at 07:52 AM 0
Share

Application.careers

8 Replies

· Add your reply
  • Sort: 
avatar image
13
Best Answer

Answer by Eric5h5 · Mar 13, 2010 at 10:03 PM

I used this in one of my scripts:


    path = Application.dataPath;
    if (Application.platform == RuntimePlatform.OSXPlayer) {
        path += "/../../";
    }
    else if (Application.platform == RuntimePlatform.WindowsPlayer) {
        path += "/../";
    }
Comment
Add comment · Show 4 · 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 Christophe F · May 11, 2010 at 06:18 AM 0
Share

thanks for this one Eric; I didn't know about this.

avatar image darkhog · Jun 26, 2015 at 02:53 PM 0
Share

How about Linux?

avatar image Rustam-Ganeyev · Jun 26, 2015 at 08:25 PM 0
Share

@darkhog, if you'd like to have read/write access, use Application.persistentDataPath

avatar image darkhog · Jun 26, 2015 at 09:32 PM 0
Share

No, it has to be next to executable as it will contain several things bundled with the game.

avatar image
5

Answer by proavus · Sep 01, 2011 at 03:34 PM

What I would do is Path.GetFullPath("."), but didn't test it anywhere except of PC

Comment
Add comment · Show 2 · 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 NateJC · Jan 13, 2015 at 09:41 PM 0
Share

This worked great for me in OS X Yosemite as well. Thumbs up!

avatar image SonnyBlueBalls · Jan 27, 2015 at 06:36 AM 0
Share

This has helped me a ton! I've looked everywhere for this!

avatar image
2

Answer by Orion_78 · Feb 27, 2017 at 03:48 PM

What I would use is Path.GetDirectoryName(Application.dataPath)

Comment
Add comment · Show 1 · 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 RDubs12 · Dec 06, 2017 at 03:39 PM 0
Share

This works perfectly. Thanks.

avatar image
1

Answer by Rustam-Ganeyev · Sep 07, 2011 at 04:45 AM

You can use Application.persistentDataPath. It's safe to write there.

Comment
Add comment · Show 2 · 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 colinday · Oct 16, 2015 at 04:35 PM 0
Share

I know this is an old thread, but using Application.persistentDataPath is absolutely where you should store configuration files, save games, logs, anything you want to exist between multiple runs of your game.

It is guaranteed to be a valid and approved location on all platforms for you to store persistent data without having to worry about platform rules, permissions, sandboxing etc.

Hacking you way around finding the application location and/or writing data files in other locations is asking for trouble on some platforms and might change in a future version of Unity.

avatar image Lloyd_RedironLabs colinday · May 29, 2016 at 12:29 AM 1
Share

Although true, this path is only known by the application instance from inside Unity. Third party tools, launchers, patchers, and middleware may not be able to correctly guess the path. And there are many cases where this is not the right solution.

Sometimes it is required for the application to be aware of its current root structure in terms of the root binary executable. However, the OP was seeking for it to go side-by-side with the executable / player package, not sure this addresses the question.

avatar image
0

Answer by qJake · Mar 13, 2010 at 09:47 PM

Well, if this were a regular Windows application, I would have told you to just use Application.StartupPath, but since it's not (and the Unity library has their own version of the Application class), I don't think what you're asking for is possible.

I'm pretty sure the dataPath variable is there for cross-platform compatibility, since the filesystems are different on Windows/Mac/iPhone, etc, so what the dataPath does is gives you a unified, safe location where you can store data, regardless of target platform.

Comment
Add comment · 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
  • 1
  • 2
  • ›

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

12 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

Related Questions

Making an ipad app without unity 1 Answer

Target frame rate between scenes 1 Answer

Storing Application.LoadedLevel As a variable not working. 1 Answer

Can you pass a variable to Application.Load level 1 Answer

Why doesn't Application.CaptureScreenshot work in Windows player? 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