لن تظهر واجهة المستخدم الرسومية Gui.Window في Unity
-
23-12-2019 - |
سؤال
لدي بعض التعليمات البرمجية مثل ما يلي:
if( GUI.Button(
new Rect(Screen.width/4f,50f,Screen.width/2f,Screen.height/9f),"RessetLevel")) {
showingWinsows = true;
if(showingWinsows)
{
rectWindow = GUI.Window(
0,
rectWindow,
DoMyWindow,
"Are you sure you want to reset All level ?"
);
}
لقد قمت بإدخال userGuiLayout = false;
في Awake()
وظيفة.لكن النافذة ما زالت لا تظهر.كيف يمكنني حل هذه المشكلة؟
المحلول
المشكلة هي أن النافذة يتم رسمها فقط عند الضغط على الزر.
أنت بحاجة إلى نقل الكود الذي يتحقق من العلامة خارج if (GUI.Button)، شيء من هذا القبيل:
if( GUI.Button(new Rect(Screen.width/4f,50f,Screen.width/2f,Screen.height/9f),"Resset Level"))
{
showingWinsows = true;
}
if(showingWinsows)
{
rectWindow = GUI.Window(0,rectWindow,DoMyWindow,"Are you sure you want to reset All level ?");
}
لا تنتمي إلى StackOverflow