- Home /
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.
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
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.
@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.
Ok, my fault. Didn't know .psd files where imported as texture2d :). This clarifies it. Thanks.
Your answer
Follow this Question
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
EditorWindow: Use toggle to disable/enable other controls? 1 Answer
Text in custom editor is displayed/rendered with boxes around characters... 2 Answers