- Home /
Accessing GameObjects from Editor static class in Plugins...not.
Hey guys.
So basically I'm making an EditorWindow class to display various custom functions and well, anyway, I need to access a GameObject from the Hierarchy(in-game) in Editor mode. I'm using a simple:
if(!GameObject.Find("$MyGO")){
myGO = new GameObject(); myGO.name = "$MyGO";
}
Now it will create the GameObject once, and only once. Yet I 'lose the reference' as soon as the if(){} block end (myGO return null).
I'm using a JScript class located in my Plugins folder as an EditorWindow. The function is static and so is the variable, declared and casted outside the function, inside the class.
Any hints/tips on what's happening/what I should do? Thanks!
Answer by by0log1c · Apr 08, 2011 at 10:57 PM
Duh.
FindObjectOfType(TheType);
FindObjectsOfType(TheType);
does return whatever I need from the Hierarchy. I just have to iterate through the result.
Sorry/Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220613121702im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Does Unity overwrite static values on play? 1 Answer
[RESOLVED]How to get all available parameters from target Component 3 Answers
How do I wait until after AssetDatabase creates an assets before carrying out another function ? 0 Answers
Change Editor Cursor 1 Answer
How to "paint" objects in the editor? 3 Answers