I want to extend the functionality of unity editor, so I just follow the rules of the documentation:
public class HelloWorldWindow : EditorWindow
{
string myString = "Hello World";
bool groupEnabled;
bool myBool = true;
float myFloat = 1.23f;
[MenuItem ("Window/HelloWorld")]
static void Init()
{
HelloWorldWindow window = (HelloWorldWindow)EditorWindow.GetWindow(typeof(HelloWorldWindow));
}
void OnGUI()
{
...
}
}
After editing this C# class, I got my new class file compiled, yet I got a warning from the compiler:
“warning CS0219: The variable `window’ is assigned but its value is never used”
So is there anybody know how to get rid of this warning?
Since I’m new to C# (I used to use C++), this piece of code seems magic to me, because I can see the variable “window” be used nowhere, could anybody please explain how this window guy works behind the scene?