Communication between editor scripts

Hi all,

I have a Custom Inspector and I want to have a preview for my inventory and i know that the OnPreviewGUI() is only for assets. So I’ve created an EditorWindow script. But…when I use this :

this.inventaireScript = GameObject.Find("GestionGUI").GetComponent<GestionGUI>;

I have this error :

Anyone have on idea on this ?

Thanks in advance.

Is GestionGUI a .cs script? As in do you have a class name GestionGUI that inherits from Monobehaviour?

GestionGUI is a .cs script yes but GestionGUI inherits from Editor so i can’t inherits it a second time.

SO that means you can’t use getcomponent since get component is only applicable to classes that are inherited by GameObject/Component classes.

It’s what i thinked but then …do you have a solution to have access to the variables that are into the GestionGUI script ?

Can’t really think of any other way. Think you can declare some of the variables as static so you need not instance the class to use it. :smile:

…indeed this idea isn’t stupid :slight_smile: Sometimes i think complicated… I’ll try it when i’ll come back to home.

thanks it works …better because it’s just that now my static variables aren’t shown in the inspector …and there are to be shown :confused:
There are some posts on that kind of problem so i’ll work a bit on that before ask again.

it works now… I made this class in ConfigurationGUI.cs

[System.Serializable]
public class Styles
{
	public  GUIStyle styleFenetre;
	public  GUIStyle styleBoite;
	public  GUIStyle styleOnglets;
}

and I have declared it :

public Styles styles;

then in the Update function :

inventaireScript.styleFenetre = styles.styleFenetre;

And into GestionGUI.cs i create :

public static GUIStyle styleFenetre;
public static GUIStyle styleBoite;
public static GUIStyle styleOnglets;

in OnInspectorGUI :

styleFenetre = (target as ConfigurationGUI).styles.styleFenetre;
styleBoite = (target as ConfigurationGUI).styles.styleBoite;
styleOnglets = (target as ConfigurationGUI).styles.styleOnglets;

Thanks again :wink:

Wow. Cool. Okay glad it works out for you. And good job on figuring it yourself. :smile: