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 UltimateWalrus · Jun 05, 2013 at 09:59 PM · xmlresources

File extensions other than XML in Resources?

When doing Resources.Load, if the extension of a file is known to Unity (like *.xml) it'll load it into a TextAsset just fine. But if it's an unknown file extension, it gets ignored.

I'm using OGMO Editor for a 2D tile-based game I'm making in Unity. It saves its levels in XML format, but they are of the extension .oel. Every single time I save a level, I've been having to manually copy and rename it from .oel to *.xml in explorer, which is extremely annoying and time consuming.

Is there any way to get Unity's resource manager to accept file types other than the arbitrary ones it already knows about?

Thanks!

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
1
Best Answer

Answer by Bunny83 · Jun 05, 2013 at 10:17 PM

No, i don't think there's a way to make Uniyt accept other types. However you can write an editor script which does the renaming for you. Depending on what kind of game it is and what platform you target you could use external files. Either load them from a subfolder (standalone, mobile) or load them from a webeerver (webplayer, mobile)

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 UltimateWalrus · Jun 05, 2013 at 10:31 PM 0
Share

Thanks for your response.

That's really frustrating... I've already had to roll my own audio manager, input manager, game object base class (allowing update ordering), and purchase a library for 2D sprite rendering. Now I have to program my own file handling?

I thought Unity was supposed to be a full-featured game engine? Perhaps I'll look into alternatives for my next project.

avatar image UltimateWalrus · Jun 14, 2013 at 03:08 AM 2
Share

I have to say though I was pleasantly surprised how easy it was to write the editor script. Here's my quick-and-dirty script for anyone else who needs to do this:

 using UnityEditor;
 using UnityEngine;
 using System.IO;
 
 
 public class BatchRenamer
 {
     [$$anonymous$$enuItem("BeatBros/Rename *.oel to *.xml %r")]
     public static void RenameOELToX$$anonymous$$L()
     {
         DirectoryInfo info = new DirectoryInfo("Assets/Resources/Levels");
         FileInfo[] fileInfo = info.GetFiles();
         foreach(FileInfo file in fileInfo)
         {
             if(file.Extension.ToLower() == ".oel")
             {
                 string newname = "Assets/Resources/Levels/" + file.Name.Substring(0, file.Name.Length-3) + "xml";
                 
                 FileUtil.DeleteFileOrDirectory(newname);
                 FileUtil.CopyFileOrDirectory( file.ToString(), newname);
             }
         }
     }
 }

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

15 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

Related Questions

Loading XML file from resources file after Build 6 Answers

Write to XML-file within Assets\Resources 1 Answer

Different approach to loading XML data 1 Answer

Load xml from resource folder after build(web player) 0 Answers

Include a file to build - and keep it editable 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