- Home /
How to remove GUILayer?
Now my current problem is this, that when I call the first NPC OnGUI function as a dialogue. After I finish with first NPC, and move on to the second NPC, the first NPC OnGUI function and the second NPC OnGUI function run together.
Is there any way to remove the previous OnGUI function so that it won't stack together?
That depends entirely on how you're coding it. You would use some kind of program logic to prevent it, but since I don't know your code I can't be more specific than that.
Answer by Jake.OConnor · Dec 13, 2012 at 07:38 PM
Without being able to see your code, I'll just have to give you two valid answers that might apply.
1) Disable the GameObject or script controlling the first NPC's GUI functionality so that OnGUI doesn't get called anymore.
2) Disable the OnGUI function from within the script. Place a public, boolean member in the script, then have it set to be false when the other NPC needs to talk. In your OnGUI function place everything in a if( booleanMember ){} block.
Answer by Nidre · Dec 14, 2012 at 01:40 PM
im not sure if understood you question correctly.Hard to be sure without seeing the code but you can set useGuiLayout = false to disable OnGUI from begin called on the NPC you are done with.
Your answer