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
3
Question by TylerMorton · May 10, 2017 at 03:33 PM · assetcustomfilesstorage

Is it possible to reference a custom file type in the inspector?

Hi guys,

For context, I'm working on a strange project right now where all of the 3D models, bone layouts and animations are in formats not native to Unity. I've written custom asset importers for all of the file types, but now I'd like to link them up in a way that creates an easy workflow.

How can I reference a file that is NOT a UnityEngine.Object or .asset file in a script? For example, is it possible in code to have an inspector field that is looking for file types of .png, .jpg, .xx, .random, ect? If not, are there any workarounds?

Thanks in advance!

Comment
Add comment · Show 3
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 AlwaysSunny · May 10, 2017 at 10:06 PM 0
Share

An EditorGUILayout.ObjectField can accept any type. It could be as simple as supplying the asset's type to the field's type argument.

Edit: I see you're looking for files, not imported assets. Not sure how to expose a field for those. I'd be interested to see, too.

avatar image RobAnthem AlwaysSunny · May 10, 2017 at 10:09 PM 0
Share

No this doesn't work for object types that unity does not support.

However, I've created custom editor windows for editing and creating non-unity objects and storing/loading them through binary formatters. It is quite simple, but it doesn't work the way a normal inspector does. This is a habit I developed from working outside Unity, since all programs have data objects that need created/edited. Or at least most do.

avatar image $$anonymous$$ · Sep 21, 2017 at 11:23 PM 0
Share

@Tyler$$anonymous$$orton I think that he means to USE the custom file type. Just as an example, I have a crap ton of $$anonymous$$$$anonymous$$P files. They contain points and identification for each point. I would want the inspector to be able to display and edit the points and their IDs. Each ID referencing a model or effect area.

1 Reply

· Add your reply
  • Sort: 
avatar image
5

Answer by Arkaid · May 11, 2017 at 05:59 AM

AFAIK. No. However, unity takes files "as is", if they end with .bytes, and then you can read it with TextAsset.bytes

So, it might be a bit annoying, but you could do it so files add an extra extension so it ends in bytes. For example, say you had myfile.random, you could make it so it's myfile.random.bytes, and then work from there. It's bothersome, but it's the only workaround I can think of.

Comment
Add comment · Show 5 · 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 RobAnthem · May 11, 2017 at 06:05 AM 0
Share

This still cannot be inspected in the inspector, only Resources can read .bytes files and it HAS TO of been formatted with a binary formatter, or the .bytes extension is meaningless.

avatar image Arkaid RobAnthem · May 11, 2017 at 06:13 AM 2
Share

I don't get what you want to do. You said "referenced" in the inspector. I made a test project and I can take any file (even a text file), slap the .bytes extension and assign it to a GameObject's script, then read it with TextAsset like so

 public class TestAsset : $$anonymous$$onoBehaviour 
 {
     public TextAsset theFile;
     private void Start()
     {
         // do something here with theFile.bytes;
     }
 }

You don't need to use Resources this way. It just reads it when the project runs.

avatar image RobAnthem Arkaid · May 11, 2017 at 06:17 AM 0
Share

Sorry, yeah they can be referenced, I meant they cannot be inspected. However this still does not solve the OP's issue unless he is willing to binary format every one of his custom objects, which may not even be possible considering the [System.Serializable] limitation.

Show more comments
avatar image Wollbobaggins · Mar 21, 2021 at 07:26 PM 0
Share

Thanks, this is exactly what I was looking for. Awesome!

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

70 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

Related Questions

Build settings: how to export files into the build 1 Answer

A way copy my extra files to the Build? 2 Answers

Create / preserve file in asset folder. 2 Answers

Assign a Material temporary (Will function in the built layer) 2 Answers

Where am I put 3d models in my custom unity package 2 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