Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by heyx3 · Feb 02, 2016 at 09:53 PM · c#prefabunityeditoreditor-scriptingprefabutility

PrefabUtility.CreatePrefab() results in "not a valid asset file name" error?

I'm trying to create a new prefab in an editor script based on a pre-existing GameObject in the scene by using UnityEditor.PrefabUtility.CreatePrefab(pathStr, obj). The specific path I'm using for testing is Assets\TreeGen\Tests\Baked Trees\Tree1\Tree1Original.prefab; as far as I can tell based on Google searches, this is the correct way to pass in the prefab name (i.e. using a path starting in "Assets", and including the ".prefab" at the end). However, I get an error:

'Assets\TreeGen\Tests\Baked Trees\Tree1\Tree1Original.prefab' is not a valid asset file name.

UnityEditor.PrefabUtility:CreatePrefab(String, GameObject)

CurveMeshEditor:BakeToFile(String) (at Assets/TreeGen/Editor/CurveMeshEditor.cs:124)

CurveMeshEditor:OnInspectorGUI() (at Assets/TreeGen/Editor/CurveMeshEditor.cs:78)

UnityEditor.DockArea:OnGUI()

Am I using this method wrong?

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
1

Answer by CommanderThrawn · Dec 10, 2016 at 01:01 AM

Looks like the problem is related to using "/" vs "\". Try replacing with "/" and see if it works, looks like it did for me. Good luck!

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
avatar image
0

Answer by ChrissTman · Aug 31, 2016 at 12:24 PM

Ye, me to :/ and i found even your Redit post and my path has only 82 chars, so we will have to just wait for bugfix.

Im just curious, how did you do the workaround to this whole problem that doesn't involve prefabs ?

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 heyx3 · Sep 01, 2016 at 04:02 AM 0
Share

It's very specific to my project; I just decided not to use prefabs at all. It's part of an editor plugin, and the prefabs were just a bit of convenience that I did so the user wouldn't have to make prefabs manually.

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

80 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 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 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 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

Comparing a gameObject's source prefab with a prefab 0 Answers

PrefabUtility.RevertPrefabInstance() not working 2 Answers

How to add a component from a Custom Editor object field to a Prefab ? 1 Answer

How to i use get key to use the turn? 1 Answer

Change starting scene based on file 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