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 FireSBurnsmuP · Apr 10, 2015 at 04:45 PM · serializationscriptableobjectassetdatabase

Creating ScriptableObject Asset "Failed to write meta file"

Okay, so I'm attempting to create a level editor that requires creating several assets, one for each campaign, then the maps in the campaign, the missions in each map, then the enemies in those missions. The structure is being saved in /Assets/Resources/Campaigns using editor tools, then the game loads them at run-time and builds the GUI.

The problem only occurred when getting down to the Enemies in the Missions. A new Campaign gets created and stored in Assets/Resources/Campaigns/[campaign-id].asset using AssetDatabase.CreateAsset(), then the same happens for a new Map, in Assets/Resources/Campaigns/[campaign-id]/[map-id].asset, then the same happens again for each new mission in the map, at Assets/Resources/[campaign-id]/[map-id]/[mission-id].asset.

But when I use the same code to create an asset for an enemy in that mission, at Assets/Resources/Campaigns/[campaign-id]/[map-id]/[mission-id]/[enemy-id].asset, CreateAsset throws an error, popping up a window, as below:

alt text

If I click 'Cancel' a few times, because it will pop up a bunch of times, eventually it will stop showing up, and the console will log the error:

 Failed to write meta file 'Assets/Resources/Campaigns/[campaign-id]/[map-id]/[mission-id]/[enemy-id].asset.meta'
 UnityEditor.AssetDatabase:CreateAsset(Object, String)
 MissionDrawer:OnGUI(Rect, SerializedProperty, GUIContent) (at Assets/Editor/MissionDrawer.cs:175)
 UnityEditor.EditorGUILayout:PropertyField(SerializedProperty, GUIContent, Boolean, GUILayoutOption[])
 MapDrawer:OnGUI(Rect, SerializedProperty, GUIContent) (at Assets/Editor/MapDrawer.cs:354)
 UnityEditor.EditorGUILayout:PropertyField(SerializedProperty, GUIContent, Boolean, GUILayoutOption[])
 CampaignDrawer:OnGUI(Rect, SerializedProperty, GUIContent) (at Assets/Editor/CampaignDrawer.cs:158)
 UnityEditor.EditorGUILayout:PropertyField(SerializedProperty, GUIContent, Boolean, GUILayoutOption[])
 LevelSelectUIManagerEditor:OnInspectorGUI() (at Assets/Editor/LevelSelectUIManagerEditor.cs:285)
 UnityEditor.DockArea:OnGUI()


I'm using the same methods as the others, and the .asset file gets created. My editors work properly after that, and the values all stay put. It's just that the .meta file for the asset never gets created, and every time it tries (i.e. whenever importing anything else), it fails to create the .meta and the error window pops up a billion times again.

Any suggestions? The code block that gets executed to create the asset is as follows:

 if(GUILayout.Button("Add New"))
 {
     Enemy newEnemy = ScriptableObject.CreateInstance<Enemy>();
     newEnemy.mission = mission;
     string enemyPath = msnPath + "/EN-" + newEnemy.GUID.ToString() + ".asset";
 
     if(!System.IO.Directory.Exists(msnPath.Replace("/", "\\")))
     {
           System.IO.Directory.CreateDirectory(msnPath.Replace("/", "\\"));
     }
 
     mission.Enemies.Add(newEnemy);
 
     AssetDatabase.CreateAsset(newEnemy, enemyPath);
 
     AssetDatabase.SaveAssets();
 
     serMission = new SerializedObject(mission);
 
     EditorUtility.SetDirty(mission);
 }

It's exactly the same as the blocks that create a new Mission, or Map, or Campaign, and those all work without a hitch.

I've tried rebooting Unity, rebooting the computer, deleting and re-downloading the project, and finally uninstalling and reinstalling Unity, and nothing works. The computer is a Windows 8.1 laptop.

Thanks in advance.

2015-04-10-01-24-02-unity.png (9.7 kB)
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 FireSBurnsmuP · Apr 15, 2015 at 06:35 AM

Okay, so apparently there's a path-length limit in Windows, and I was pushing it. The .asset files could get created, but that extra 5 characters for the .meta pushed it over the limit.

From the MSDN feedback forums:

[...] 248 characters for the maximum path length and 260 for the maximum filename length.

I reorganized the structure a bit, to shorten the paths, and now it's functioning properly.

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

2 People are following this question.

avatar image avatar image

Related Questions

AssetDatabase.LoadAssetAtPath() not working after any sort of project change. 0 Answers

Using System.Object in ScriptableObject 1 Answer

AddObjectToAsset (reference) becomes null 1 Answer

.asset file containing ScriptableObject is empty on openingUnity 1 Answer

Scriptable Object references if not saved in AssetDatabase? 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