Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411421 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 10:18:57 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Getting References to Assets Programmatically in the Editor
Pages: [1]
Print
Author Topic: Getting References to Assets Programmatically in the Editor  (Read 631 times)
bateleur
Level 10
*****



View Profile
« on: August 04, 2017, 02:53:38 AM »

For a project I'm working on I have a custom EditorWindow I use for various things. One of the things I now want to do with it requires a Material. The Material already exists, but it's not clear to me how to get a reference to it from the EditorWindow script.

If this were runtime code I'd either have a reference from an object in the scene or use Resources.Load, but neither of these is OK in this case. I can't reference from the scene since this EditorWindow is a debugging tool which needs to work with any scene. I can't use Resources.Load, because that would cause the Material to be added to the runtime resource bundle, which is wrong.

What's the best way to do this? Failing that, what's the least horrible hack that will work?
Logged

oahda
Level 10
*****



View Profile
« Reply #1 on: August 04, 2017, 04:40:34 AM »

http://answers.unity3d.com/questions/1170405/resourcesload-without-a-resources-folder.html
Logged

bateleur
Level 10
*****



View Profile
« Reply #2 on: August 09, 2017, 02:46:17 AM »

Aha, thanks. So basically just AssetDatabase.LoadAssetAtPath() - that's nice and easy!  Hand Thumbs Up LeftTiger
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic