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
1
Question by Steven-1 · Jan 09, 2013 at 01:13 PM · assetdatabase

How can AssetDatabase.CreateFolder() possibly work?

I don't get how it can work (and consequently, I can't make it work);

I just want to create a folder, but it fails (without even throwing an error)

I don't see how anything but a toplevel folder can be made with CreateFolder (parentFolder : String, newFolderName : String)

seeing as there can be more than 1 folder with the same name in a project, how can unity possibly know which folder I mean with parentFolder ?

My guess was that waht they actually want is the path to the parent folder, but that doesn't work either.

So anyone knows how it works? bether yet, how to correctly use it?

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

2 Replies

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

Answer by Dave-Carlile · Jan 09, 2013 at 01:26 PM

From the documentation, the root folder appears to be the Assets folder. So if you want to create your folder directly within your Assets folder, pass "Assets" as the parent. If you want a subfolder under that, then do "Assets/My Folder".

e.g.

 AssetDatabase.CreateFolder("Assets", "My Folder");
 AssetDatabase.CreateFolder("Assets/My Folder", "My Sub Folder");


Edit: Corrected to use forward slashes per Bunny83, added examples

Comment
Add comment · Show 6 · 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 Bunny83 · Jan 09, 2013 at 01:44 PM 2
Share

The asset database always use forward slashes :-)

avatar image Steven-1 · Jan 09, 2013 at 02:01 PM 0
Share

but that's what I was dooing, and it didn't work. hm, now I'm confused.

Edit: Never$$anonymous$$d, I accidently included the name of the new folder into the path of the parent folder.

anyway, Thanks, I dunno which one of you 2's answers to accept, since they're both partially right (1st one about forward slashes, 2nd one about "Assets"), so I just gave both a thumbs up

avatar image Bunny83 · Jan 10, 2013 at 12:15 AM 0
Share

Thanks, never$$anonymous$$d, i wrote my answer on my tablet so i couldn't include much examples ;) Always tick the best answer.

avatar image darkoleptiko · Aug 13, 2014 at 07:00 AM 4
Share

Important!! make sure you dont have a trailing slash in the parent

this wont work: AssetDatabase.CreateFolder("Assets/", "$$anonymous$$y folder");

avatar image CyrilGhys darkoleptiko · Apr 14, 2020 at 09:44 PM 0
Share

Ahhhhh thank you, you are the only one I stumbled onto who say this ! And yes, this issue is still a thing in 2020

avatar image rastabbq · Sep 13, 2014 at 06:17 PM 0
Share

thanks darkleptiko - I found that out the hard way and thankful for the confirmation. nice of them to mention that little nugget in the docs... :\

avatar image
4

Answer by Bunny83 · Jan 09, 2013 at 01:21 PM

I'm pretty sure parent folder is an asset path. So it's a path with forward slashes which start in the assets folder. So just remove the first part of your path.

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

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

11 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

Related Questions

Please Help With Folder Creation Script 0 Answers

AssetDatabase.CreateFolder question 1 Answer

AssetDatabase.CreateFolder not defined? 2 Answers

When looping through assetbundle assetdatabase how do you reference a material object 0 Answers

Proper way to refresh asset 0 Answers


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