• 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 hexdump · Sep 21, 2015 at 05:11 PM · editor-scriptingeditorwindoweditorguieditorguilayout

Drag a non standard unity asset on a custom editor slot

Hi,

I have a .psd file that I want to handle in unity. I'm builidng a little gui window where the player has to drag the file onto it. I guess I should be using ObjectFIeld for that but not sure how to do it. Could anyone give any tip?

Cheers.

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
2

Answer by vintar · Sep 21, 2015 at 07:52 PM

check this, it may help : https://github.com/Banbury/UnityPsdImporter/blob/master/PhotoShopFileType/Editor/PSDEditorWindow.cs

Comment
Add comment · Show 3 · 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 hexdump · Sep 21, 2015 at 09:20 PM 0
Share

I have upvoted your answer and I am really greatefull about the informatio you have provided but this is not answering my question. I mean in the example the coder is expecting a tex2D for the type of the psd file, I think this is not the best way to do that because type doesn't match. Am I missing something?

Waiting for anyone to help with this one.

Cheers.

avatar image Bunny83 hexdump · Sep 22, 2015 at 01:43 AM 0
Share

@hexdump:
If that doesn't answer your question you might be more specific about what you want to do. You said you "want to handle a psd file in unity". When you simply drag a psd file into your project it is automatically imported as Texture2D. If you need some kind of special handling you should be more specific.

The Unity editor is designed to work with assets which are located in the assets folder. The ObjectField can only handle classes which are derived from UnityEngine.Object.

You said you want a GUI window where the user should drag and drop the file. Where does the file come from? If you talk about files which are no assets, so they are located outside of your project's assets folder, that's not possible. For that feature you would need to activate drag and drop support of the OS to make it send "W$$anonymous$$_DROPFILES" messages to your window. Since you don't have access to the editor window message pump, even when you allow drag and drop events you can't receive the data.

The only way around that would be to write a native code plugin which shows a native window which you control yourself.

Anyways, we can't suggest anything without knowing what you want to do.

avatar image hexdump Bunny83 · Sep 22, 2015 at 07:13 AM 0
Share

Ok, my fault. Didn't know .psd files where imported as texture2d :). This clarifies it. Thanks.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

28 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

Related Questions

Custom Editor - Is there any way to detect whether the user is in Prefab editing mode? 1 Answer

Positioning a button at the bottom of an editor window 1 Answer

Is it possible to store and display EditorGUILayout.Toggles? 0 Answers

Get position of Rect in Rect in EditorWindow 1 Answer

Editor GUI Foldout header style customization 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges