how to access a custom editor's public variables?

I have done this before, but I can’t find it again. I have a custom editor class, and I want to set the variables of the editor.

For example, check out killTex in the code below- this is a texture of a little red X that I use as an in-editor delete button (screenshot further below).

I can not for the life of me find out where I assigned that image to killTex. If I wanted, eg, to make it a green checkmark instead, where would I look for the linkage?

class NodeEditor extends Editor {

	// this stuff makes the node deletion button pretty
	var killTex:Texture;
	var nullStyle:GUIStyle = new GUIStyle();
	var bDim:int = 20;
	var ScreenHeightCorrection:int = 38; //the fuck?

	protected function deleteButton (pos:Vector3) :boolean {
		pos = target.transform.TransformPoint( pos );

		var bPos:Vector3 = sceneCam.WorldToScreenPoint(pos);
		bPos.y = Screen.height - bPos.y - ScreenHeightCorrection;
		bPos.y -= bDim + 2;
		bPos.x += 2;

		var del:boolean = GUI.Button( Rect(bPos.x, bPos.y, bDim, bDim), killTex, nullStyle );

		return del;

	// note: SceneView is undocumented. If at any time in the future it breaks, we will all die horribly.
	function get sceneCam () :Camera {

	function OnInspectorGUI () {

	function get owner () :NodeList {
		return (target as NodeList);

alt text

This could be done in some old Unity versions via the default references. However due to a lot of problems with serialization (as i understand it) they removed the default references from ScriptableObjects and editor scripts. Now default references can only be used for MonoBehaviours. See this question.

There was another question about this a few month ago. Officially they removed the support in version 2.1, but in Unity 3.0 it’s still possible. In the actual version 3.5+ they finally removed it completely

Now the only way to get assets in an editor script, is to either search for them or use an absolute path. There are many ways to load assets, the easiest is to use Resources.LoadAssetAtPath which is actually and editor only function, even it’s part of the Resources class.

The bigger editor extensions like Playmaker have included their images in their dll assembly and they load them manually from the dll resource.

A hacky workaround could be to create a dummy MonoBehaviour with some public variables, assign your default references to this monobebaviour script and let the editor create a temporary gameobject with that script just to get the references :wink:

Haven’t tried this yet.

Actually i miss this feature too. I always used a default reference for a custom skin in my custom EditorWindows. Well, i guess we have to live with it…