当前位置: 首页>>代码示例>>C#>>正文


C# EditorWindow.Repaint方法代码示例

本文整理汇总了C#中EditorWindow.Repaint方法的典型用法代码示例。如果您正苦于以下问题:C# EditorWindow.Repaint方法的具体用法?C# EditorWindow.Repaint怎么用?C# EditorWindow.Repaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EditorWindow的用法示例。


在下文中一共展示了EditorWindow.Repaint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowNotification

        public static void ShowNotification(EditorWindow window, string notif)
        {
            window.ShowNotification(new GUIContent(notif, ""));
            window.Repaint();

            if (EditorApplication.update != NotifUpdate)
                EditorApplication.update += NotifUpdate;

            notifTimer = Time.realtimeSinceStartup + TIMER_DISPLAY_TIME;
            notifWindow = window;
            notifDisplayed = true;
        }
开发者ID:cschladetsch,项目名称:UnityTemplate,代码行数:12,代码来源:qe_Editor_Utility.cs

示例2: EquipEditor

        public EquipEditor(string name, EditorWindow window)
        {
            this.name = name;
            this.window = window;
            this.requiresDatabase = true;

            typeList = new ReorderableList(InventoryEditorUtil.selectedDatabase != null ? InventoryEditorUtil.selectedDatabase.equipStatTypes : new string[]{}, typeof(System.Type), false, true, true, true);
            typeList.drawHeaderCallback += rect => EditorGUI.LabelField(rect, "Types to scan");
            typeList.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                rect.y += 2;

                var r = rect;
                r.width -= 60;

                var statTypes = InventoryEditorUtil.selectedDatabase.equipStatTypes;

                EditorGUI.LabelField(r, (string.IsNullOrEmpty(statTypes[index]) == false && System.Type.GetType(statTypes[index]) != null) ? System.Type.GetType(statTypes[index]).FullName : "(NOT SET)");

                var r2 = rect;
                r2.width = 60;
                r2.height = 14;
                r2.x += r.width;
                if (GUI.Button(r2, "Set"))
                {
                    var typePicker = InventoryItemTypePicker.Get();
                    typePicker.Show(InventoryEditorUtil.selectedDatabase);
                    typePicker.OnPickObject += type =>
                    {
                        statTypes[index] = type.AssemblyQualifiedName;
                        window.Repaint();
                        GUI.changed = true; // To save..
                    };
                }
            };
            typeList.onAddCallback += list =>
            {
                var l = new List<string>(InventoryEditorUtil.selectedDatabase.equipStatTypes);
                l.Add(null);
                InventoryEditorUtil.selectedDatabase.equipStatTypes = l.ToArray();
                list.list = InventoryEditorUtil.selectedDatabase.equipStatTypes;

                window.Repaint();
            };
            typeList.onRemoveCallback += list =>
            {
                var l = new List<string>(InventoryEditorUtil.selectedDatabase.equipStatTypes);
                l.RemoveAt(list.index);
                InventoryEditorUtil.selectedDatabase.equipStatTypes = l.ToArray();
                list.list = InventoryEditorUtil.selectedDatabase.equipStatTypes;

                window.Repaint();
            };

            resultList = new ReorderableList(InventoryEditorUtil.selectedDatabase != null ? InventoryEditorUtil.selectedDatabase.equipStats : new InventoryEquipStat[]{}, typeof(InventoryEquipStat), true, true, false, false);
            resultList.drawHeaderCallback += rect =>
            {
                var r = rect;
                r.width = 40;
                r.x += 15; // Little offset on the start

                EditorGUI.LabelField(r, "Show");

                var r2 = rect;
                r2.width -= r.width;
                r2.x += r.width + 20;
                r2.width /= 4.2f;
                EditorGUI.LabelField(r2, "From type");

                r2.x += r2.width;
                EditorGUI.LabelField(r2, "Display name");

                r2.x += r2.width;
                EditorGUI.LabelField(r2, "Category");

                r2.x += r2.width;
                //r2.width *= 2 - 50;
                EditorGUI.LabelField(r2, "Formatter");
            };
            //resultList.elementHeight = 30;
            resultList.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                rect.y += 2;

                var stat = InventoryEditorUtil.selectedDatabase.equipStats[index];

                var r = rect;
                r.width = 40;
                stat.show = EditorGUI.Toggle(r, stat.show);

                GUI.enabled = stat.show;

                var r2 = rect;
                r2.width -= r.width;
                r2.x += r.width + 5;
                r2.width /= 4.2f;
                EditorGUI.LabelField(r2, stat.fieldInfoNameVisual);

//.........这里部分代码省略.........
开发者ID:L4w3s,项目名称:DOOM-Inspired-Dungon-Crawler,代码行数:101,代码来源:EquipEditor.cs

示例3: RemoveNotification

        public static void RemoveNotification(EditorWindow window)
        {
            EditorApplication.update -= NotifUpdate;

            window.RemoveNotification();
            window.Repaint();
        }
开发者ID:cschladetsch,项目名称:UnityTemplate,代码行数:7,代码来源:qe_Editor_Utility.cs

示例4: ResizeWidget

        /// <summary>
        /// Draws a resize widget.
        /// </summary>
        /// <returns>
        /// The new widget state (true if resizing).
        /// </returns>
        /// <param name='state'>
        /// The current widget state.
        /// </param>
        /// <param name='resizeValue'>
        /// The current resize value.
        /// </param>
        /// <param name='minValue'>
        /// The minimum resize value.
        /// </param>
        /// <param name='maxValue'>
        /// The maximum resize value.
        /// </param>
        /// <param name='size'>
        /// The widget size.
        /// </param>
        /// <param name='resizeVertical'>
        /// If set to <c>true</c>, draw a vertical resize widget.
        /// </param>
        /// <param name='resizeArea'>
        /// The area to resize within.
        /// </param>
        public static bool ResizeWidget(
			bool state, 
			ref float resizeValue, float minValue, float maxValue, float size, 
			bool resizeVertical, Rect resizeArea, 
			EditorWindow editorWindow)
        {
            Color oldColor = GUI.backgroundColor;

            GUI.backgroundColor = new Color(.5f, .5f, .5f, 1);
            bool s = state;

            // Detect a mouse up event
            if (Event.current.type == EventType.MouseUp)
            {
                s = false;
            }

            // Draw the widget
            if (resizeVertical)
            {
                if (GUILayout.RepeatButton("", EditorStyles.toolbarButton, GUILayout.Height(size), GUILayout.ExpandWidth(true)))
                {
                    s = true;
                }

                EditorGUIUtility.AddCursorRect (GUILayoutUtility.GetLastRect(), MouseCursor.ResizeVertical);
            }
            else
            {
                if (GUILayout.RepeatButton("", vertWidgetStyle, GUILayout.Width(size), GUILayout.ExpandHeight(true)))
                {
                    s = true;
                }

                EditorGUIUtility.AddCursorRect (GUILayoutUtility.GetLastRect(), MouseCursor.ResizeHorizontal);
            }

            GUI.backgroundColor = oldColor;

            // Process events
            if (s)
            {
                if (Event.current.type == EventType.MouseDrag)
                {
                    Vector2 delta = Event.current.delta;
                    Vector2 pos = Event.current.mousePosition;

                    if (!resizeArea.Contains(pos))
                    {
                        s = false;
                        if (editorWindow)
                            editorWindow.Repaint();
                        return s;
                    }

                    if (resizeVertical)
                    {
                        resizeValue = Mathf.Clamp(resizeValue += delta.y, minValue, maxValue);
                        EditorGUIUtility.AddCursorRect (resizeArea, MouseCursor.ResizeVertical);
                        if (editorWindow)
                            editorWindow.Repaint();
                    }
                    else
                    {
                        resizeValue = Mathf.Clamp(resizeValue += delta.x, minValue, maxValue);
                        EditorGUIUtility.AddCursorRect (resizeArea, MouseCursor.ResizeHorizontal);
                        if (editorWindow)
                            editorWindow.Repaint();
                    }

                }
            }

//.........这里部分代码省略.........
开发者ID:kpro1999,项目名称:Unity-Version-Control,代码行数:101,代码来源:GUIHelpers.cs

示例5: NfoField

		/// <summary> Called when the nfo[] edit fields should be rendered </summary>
		public override void NfoField(plyDataObject data, EditorWindow ed)
		{
			// nfo[0] = 0:Currency, 1:Item
			// nfo[1] = the identifier of the attribute or item.(not used with currency selected)
			// nfo[2] = cached name of selected attribute or item

			EditorGUI.BeginChangeCheck();
			selected = EditorGUILayout.Popup("Reward Type", selected, Options);
			if (EditorGUI.EndChangeCheck())
			{
				data.nfo[0] = selected.ToString();
                data.nfo[1] = "-1";
                data.nfo[2] = "";
			}

            if (selected == 0)
            {
                GUILayout.TextField("New currency system in development");
            }
            else if (selected == 1)
            {
                if (GUILayout.Button("Select item"))
                {
                    //itemPicker = InventoryItemPicker.Get();
                    itemPicker.Show(true);
                    itemPicker.OnPickObject += (item) =>
                    {
                        data.nfo[0] = "1";
                        data.nfo[1] = item.ID.ToString();
                        data.nfo[2] = item.name;
                        selectedItem = item;
                        //data.nfo[2] = item.currentStackSize.ToString();

                        ed.Repaint();
                        GUI.changed = true;
                    };
                }
            }
		}
开发者ID:predominant,项目名称:Treasure_Chest,代码行数:40,代码来源:InventoryDiaQRewardInfo.cs

示例6: DrawDragBar

        public static void DrawDragBar(EditorWindow window, ref Rect rect, ref bool resize, ref float currentWindowHeight, int height = 6)
        {
            rect.Set(0, rect.y, window.position.width, height);
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeVertical);

            Vector2 mousePos = Event.current.mousePosition;
            if (Event.current.type == EventType.mouseDown && rect.Contains(mousePos))
                resize = true;

            if (resize)
                window.position.Contains(mousePos);

            if (Event.current.type == EventType.MouseUp)
                resize = false;

            if (resize) {
                rect.y = Event.current.mousePosition.y;
                window.Repaint();
            } else {
                float winHeight = window.position.height;
                if (winHeight != currentWindowHeight && currentWindowHeight != 0f)
                    rect.y = (rect.y / currentWindowHeight) * winHeight;

                currentWindowHeight = winHeight;
            }

            rect.y = Mathf.Clamp(rect.y, 40, currentWindowHeight - 40);
            VisualResources.DrawTexture(rect, VisualResources.dragBarGray);
        }
开发者ID:WhiteRavensGame,项目名称:JRPGTownPrototype,代码行数:29,代码来源:EditorHelper.cs

示例7: SearchBar

        public static string SearchBar(string searchQuery, EditorWindow window, bool isSearching)
        {
            EditorGUILayout.BeginHorizontal();
            GUI.SetNextControlName("SearchField");
            string q = EditorGUILayout.TextField(searchQuery, (GUIStyle)"SearchTextField"); // , GUILayout.Width(width)
            if (isSearching)
            {
                if (GUILayout.Button("", (GUIStyle)"SearchCancelButton", GUILayout.Width(17)))
                {
                    q = ""; // Reset
                    if(window != null)
                        window.Repaint();
                }
            }
            else
            {
                GUILayout.Button("", (GUIStyle)"SearchCancelButtonEmpty", GUILayout.Width(17));
            }

            EditorGUILayout.EndHorizontal();

            return q;
        }
开发者ID:predominant,项目名称:Treasure_Chest,代码行数:23,代码来源:InventoryEditorStyles.cs


注:本文中的EditorWindow.Repaint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。