- Home /
Question by
putlucky · Dec 17, 2014 at 05:44 PM ·
c#editoreditor-scripting
Accessing a game script from an editor script. C#
I need to get access to a script. I've tried both getcomponent and FindObjectOfType, I looked over the Selection API and didn't find any relevance there. My game script is within the editor folder as is my editor extension script.
The error I get when using FindObjectOfType is this:
Cannot implicitly convert type 'UnityEngine.Object' to 'FFToolKit'. An explicit conversion exists (are you missing a cast?) C:\Users\Anon\Documents\FFToolKit_v_1.0\Assets\Editor\FFToolKit.cs 55 27 UnityVS.FFToolKit_v_1.0.CSharp.Editor
I can't use inheritance on FFToolKit, the script which calls the other one, because it must inherit from EditorWindow.
I've been working through this for days and no one has been able to help.
[MenuItem("FFToolKit/Create/New ForceField/Sphere ForceField")]
public static void SphereFF()
{
EditorWindow.GetWindow(typeof(FFToolKit), false, "Sphere Editor");
FFToolKit myKit = FindObjectOfType(typeof(SphereForceField));
}
Comment
Whenever asking for help with an error you need to show us the code that is causing the error.
Try this
FFTool$$anonymous$$it my$$anonymous$$it = FindObjectOfType(typeof(SphereForceField)) as FFTool$$anonymous$$it ;