loading...
آموزش کامل نقشه کشی اتوکد مدلسازی سه بعدی به زبان فارسی
3d Rener بازدید : 132 چهارشنبه 15 آذر 1396 نظرات (0)

آموزش یونیتی Unity 5 2D  Extend Window System Order windows

 

دانلود آموزش تصویری یونیتی به زبان فارسی Unity

 

اکنون زمان ما برای پاکسازی WindowManagerEditor است. ما می خواهیم عنوان از SerializedProperties را تغییر دهیم تا چیزهایی را بیشتر مانند ویندوز تغییر دهیم و هر یک از عناصر موجود در لیست را به فیلد ورودی تغییر دهیم که به ما اجازه می دهد یک پنجره جدید از سلسله مراتب را تنظیم کنیم. اجازه دهید به پوشه editor ما برویم و روی WindowManagerEditor دوبار کلیک کنیم. در روش OnEnable ما قصد داریم برخی از خطوط جدید را اضافه کنیم و برخی از فراخوانی ها را ایجاد کنیم تا لیست ها بدانند چطور می خواهیم آن را ارائه دهیم. اولین فراخوانی که ما میخواهیم ایجاد کنیم drawHeaderCallback است. برای اضافه کردن callback ما، یک علامت برابر ایجاد کنیم و پرانتزهای باز ما را پر کنیم و کلمه Rect را تایپ کنیم، سپس فاصله را وارد کنیم. MonoDevelop به طور خودکار شروع به تکمیل بقیه Callback ما برای ما خواهد کرد. اولين مورد را در فهرست انتخاب کنيد و مي خواهيد اطمينان کنيد که دومين گزينه باز کردن را پاک کنيد. حالا که ما تماس برگشتیم، بقیه روش ما را اضافه می کنیم. برای تغییر سرصفحه، ما قصد داریم یک برچسب جدید ایجاد کنیم. ما فقط به EditorGUI می گوئیم تا یک برچسب ایجاد کنیم. برای نشان دادن یک موقعیت، از Rect ارائه شده استفاده می کنیم، و ما آن را "Windows" نام خواهیم برد. بیایید تغییراتمان را حفظ کنیم و به وحدت برسیم تا ببینید آیا این کار می کند. ما بوم را انتخاب می کنیم و به مدیر پنجره می رویم. همانطور که می بینید هدر ما اکنون به "ویندوز" تغییر کرده است. بیایید بررسی کنیم که چگونه می توانیم هر یک از عناصر ارائه شده را رفع کنیم. بازگشت به MonoDevelop، اجازه دهید یک تماس تلفنی جدید به لیست اضافه کنیم.

Now, let's set the drawElement callback on the list. Again, our callback is going to take a Rect, and as you hit space, MonoDevelop is going to autocomplete again all of the arguments we need for this callback method. We'll select the first option which supplies Rect an "index" and "isActive" and "isFocused" option. Again, remember to delete the beginning parenthese, and let's close our callback method. Now we're going to need to get the actual element that we want to display. We'll do this by looking at the SerializedProperty of the reorderable list. Let's create a new variable for the element. We'll look at our list, get the SerializedProperty from the list, and now let's call the GetArrayelementAtIndex method, and pass in the index value that is supplied by the callback. Now we have a reference to the element inside of the array. Next, we're going to want to create a property field. So let's use the EditorGUI to create a new PropertyField. The PropertyField is going to take the serialized data and figure out the right field to display based on the data type. In this case, each item in our array is going to be a generic window, so it will type it to that. Here we're going to pass in a new Rect based on the Rect that's being supplied in. We'll use the Rect.x, the Rect.y, and now we're going to use the screen's width minus 75. When you're building custom UI elements, you can always get the width of the window that the UI element is in by calling Screen.width. We're subtracting 75, which will take into account the fact that this element is going to be indented inside of the UI element and the other chrome around it. Finally, we're going to need the height, and we're going to use a static variable called singleLineHeight, which is part of the EditorGUIUtility class. We'll close off this Rect's constructor, and the last two values we'll pass in is the element itself, and we want to set a "none" style, so we'll pass in the GUIContent's "none" value. Now, let's save this editor and go back into Unity. Once Unity recompiles, you should now see that we have an orderable list, and in each element, we can now add any of the windows that are part of the hierarchy . If you reorder these, they'll save their position, you'll actually mess up the connections inside of each of the windows. And that's because we're going to need to come up with a way of standardizing how windows navigate to each other.

تعداد صفحات : 136

اطلاعات کاربری