Set content of ObjectField from Editor Script
To start, I realise what I'm about to ask sounds like I'm doing something hacky and stupid, and that's because it is hacky and stupid, but I'm 99% sure that this is the only possible way to accomplish what I'm trying to do. See the long version of this question for context.
Short ver: I have a GameObject in my scene with a component on it. That component's GUI layout has hundreds of ObjectFields on it; I need to set every single one to a different asset in my project. It's not feasible for me to set these all by hand. Using an Editor Script, how can I set each of these to an asset?
Long ver: I'm working with VRChat's Udon scripting system, which is very similar to regular scripts except with a handful of restrictions. The restriction I'm trying to work around now is that it's not possible to load assets at runtime in any way; if I want to access an asset in an Udon script, it has to be assigned to a public variable on that same script before runtime. I need to be able to access many TextAssets in my project, so I've created a public variable for every single one. I can't simply set these variables from a C# script because C# scripts can't access fields on Udon scripts. So I specifically need to access the EditorGUILayout on the UdonBehaviour component and set each of the variables that way. Unless there's something I'm missing, I think that's my only option.
Your answer
Follow this Question
Related Questions
Object field in the scene view - Custom Editor Script 0 Answers
Can't update ObjectField after object is selected 1 Answer
Trying to add EditorGUILabels and am getting a couple errors. 0 Answers
How to highlight non MonoBehaviour scripts from editor window 0 Answers
How to return the default value for EditorStyles.toolbarButton.normal.background ??? 1 Answer