
اکنون وقت آن رسیده است که ما بتوانیم استانداردی را که ما در میان پنجره های مختلف حرکت می کنیم، ارائه دهیم. از آنجایی که ما یک راه ساده تر برای ما برای مرتب سازی مجدد پنجره ها ایجاد کرده ایم، بگذارید پیش برویم و راه را که هر یک از این پنجره ها در حال وصل شدن است پاک کنیم. برای خیره شدن، ما قصد داریم تا به پوشه ویندوز برویم و یک اسکریپت جدید C ایجاد کنیم و ما این پنجره Enums را تماس می گیریم. بیایید این اسکریپت را باز کنیم و همه چیز را درون آن حذف کنیم. من دوست دارم از Enums استفاده کنم زیرا به من اجازه می دهد تا به جای استفاده از رشته های جادویی به مقدار بسیار خاصی تایپ کنم. یک رشته جادویی زمانی است که شما به سادگی از نام یک پنجره استفاده می کنید که می تواند در طول زمان تغییر کند. یک Enum اجازه می دهد تا ما یک نقشه ثابت بین موقعیت واقعی آرایه و پنجره ای که داخل آن قرار گرفته است داشته باشیم. برای نشان دادن این که چگونه این کار می کند، اجازه دهید یک Enum عمومی ایجاد کنیم، و ما قصد داریم با این ویندوز تماس بگیریم. در داخل Enum ما قصد داریم چهار ارزش را تنظیم کنیم. ما با هیچ، Start، GameOver و Keyboard شروع خواهیم کرد. حالا این Enum را ذخیره کن Enum می تواند در فضای نامنظم زندگی کند و همانطور که ما تازه ساخته ایم جهانی باشد. لازم نیست که به یک کلاس متصل شود، و در واقع، این Window Enum، C اسکریپت تیز، هنوز هم اجرا می شود و برای سایر پنجره های ما قابل دسترسی است. برای نشان دادن چگونگی استفاده از این، به پنجره عمومی ما بروید و یک روش تماس بعدی بعدی و قبلی را اجرا کنید. اولین چیزی که میخواهیم انجام دهیم این است که دو میدان عمومی جدید ایجاد کنیم. ما قصد داریم هر قسمت را به پنجره Enum که ما فقط آن را ایجاد کرده ایم تایپ کنیم. نخستین پنجره پنجره بعدی نامیده می شود، و دومین پنجره پنجره قبلی نامیده می شود. بعدا میخواهیم دو روش ایجاد کنیم. اجازه دهید این کار را در پایین کلاس انجام دهیم. یکی از اولین روش ها، یک روش عمومی با نوع بازگشتی از void است که بر روی Next Window نامیده می شود. در آن، ما قصد داریم مدیر را برای باز کردن Enum که ما برای پنجره بعدی تنظیم کرده ایم، اعلام کنیم. اما ترفند این است که ما باید Enum را به یک شماره واقعی تبدیل کنیم. ما قصد داریم Enum را به عنوان اینتر انتخاب کنیم، سپس نام فیلد را تعیین می کنیم.
Now we're able to take the position of this Enum and use it as an int. There's one thing that we have to do, though. If you remember back to our Windows Enum, our first one is set to none, but our array starts at index zero. So, in order to account for this, we're going to want to subtract one from the value of the converted Enum. Our window manager is smart enough to know that if we get a value such as negative one, that it's not going to open a window and it's going to ignore the request. Let's create one for the previous window and use the Previous Window field exactly like we do on Next Window. Here you'll see we're supplying the previous window and subtracting one, just like we did before. Now we're going to need to go back and clean up each of our windows. Let's go to the start window, and modify the New Game to call on Next Window. For GameOver, we're going to call on Next Window as well. And, finally, for the Keyboard window, on Accept we'll call on Next Window, and on Cancel, we'll call on Previous Window. Now you might be thinking, why don't we just extend the On Next Window or On Previous Window directly? While we can do that, it might be safer to keep these methods completely separate and untouched. This way, each of our windows can do separate logic before we call the On Next Window or On Previous Window. It all depends on your style of coding, but, for now, this is an easy approach that'll get everything up and running. Let's save all of our changed and go back into Unity. From here, we're going to want to modify each of the windows. So select the Start window, scroll down to its window class, and you'll now see that we have Next Window and Previous Window, with two drop-downs. This is one of the powerful things about using Enums in order to set values. Unity's inspector will give us a clean way of selecting a value, instead of us having to remember an id, or having to type in a magic string. Let's select the GameOver as our next window from the Start window. On the GameOver window our next window is going to be Keyboard, and on the Keyboard window, our next window will be Start, and our previous window is going to be the GameOver. Let's save our changes and run it, just to make sure that everything is working how it's supposed to. And that's it. We now have a much cleaner way to link our windows together.

