Calling EditorUtility functions from a script

Hi.

I’ve made a small editor, that run into unity editor (a texture painter). I’d like to call functions like “DisplayDialog” in it, but i’ve found no way to do that.

Last test was an editor script i could call from the main script, but it look like editor script are not visible to behaviours… “error CS0103: The name `Tools’ does not exist in the current context”

If anyone has an idea, i’d be thanksfull :slight_smile:

using UnityEngine;
using UnityEditor;
using System.Collections;

public class Tools
{
	public void GetAPath()
	{
		EditorUtility.DisplayDialog("Select Texture","You Must Select a Texture first!", "Ok");
	}
}

Regular MonoBehaviour scripts on Game Objects can’t call editor scripts or functions, no; editor functions can only be called from scripts in the Editor folder of your project, and those are not made available in a running game (since, by definition, the editor isn’t available in a game build).

However, if what you’re writing is an editor script / custom editor window, why do you need to call into it from a behaviour?

humm… it sound so logical when you say it :slight_smile:
Guess it’s because i have to learn how to do the same in an editor script, when it was easy for me as a behavior. But you’r right, so i’ll search this way.

Thanks laurie.