hi there ! i write an script , this script drag in object. if click on object must show a GUI window. but this have a error where is prob ? tnx sry 4 my lang
OnGUI should not go inside OnMouseDown(). Code (csharp): var clicked = false; function OnMouseDown() { clicked = true; } function OnGUI() { if (clicked) windowRect = GUI.Window (0, windowRect, WindowFunction, "My Window"); }
thank's pakfront , but it not work ! this have error , "Unknow identifier : WindowFunction" what's prob ?
Mr.Dawoodi, pakfront was simply illustrating where OnGUI() should go since it was in the wrong place in your original code. Apply that lesson to your original code, don't replace all your code with his. I.e., you still must define windowRect and WindowFunction. Tip #1: Watch your indentation when you add curly braces. After every { it's a good practice to add a level of indentation e.g. with a <tab> or a few spaces, and after every } to remove a level of indentation. This makes your code easier to read/understand and makes you less likely to forget of misplace an { or an }. Tip #2: When you post code, enclose them in CODE rather than QUOTE. You may have to click "Go Advanced" to see that option. It'll look like a # sound. This makes your code easier to read on the forums. Example without these tips: Example with these tips: Code (csharp): if (song.title == "paint it black") { if (door.color == "red") { door.paint("black"); } }
if you are using the code like that function OnMouseDown() { function OnGUI() { windowRect = GUI.Window (0, windowRect, WindowFunction, "My Window"); } function WindowFunction (windowID : int) { } the WindowFunction would need a parameter, cuz if it doesnt have it, it means that is a var not a function Unknown identifier means that WindowFunction was not instantiated as a var or not called by the right way as a function well this issue was a week ago hope it helps anyway