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


C# GUIStyle.Draw方法代码示例

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


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

示例1: OnPreviewGUI

 public override void OnPreviewGUI(Rect r, GUIStyle background)
 {
     if (Event.current.type == EventType.Repaint)
     {
         background.Draw(r, false, false, false, false);
     }
     MovieTexture target = base.target as MovieTexture;
     float num = Mathf.Min(Mathf.Min((float) (r.width / ((float) target.width)), (float) (r.height / ((float) target.height))), 1f);
     Rect viewRect = new Rect(r.x, r.y, target.width * num, target.height * num);
     PreviewGUI.BeginScrollView(r, base.m_Pos, viewRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
     EditorGUI.DrawPreviewTexture(viewRect, target, null, ScaleMode.StretchToFill);
     base.m_Pos = PreviewGUI.EndScrollView();
     if (target.isPlaying)
     {
         GUIView.current.Repaint();
     }
     if (Application.isPlaying)
     {
         if (target.isPlaying)
         {
             EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode");
         }
         else
         {
             EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode");
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:28,代码来源:MovieTextureInspector.cs

示例2: SelectionList

    public static int SelectionList(int selected, GUIContent[] list, GUIStyle elementStyle, DoubleClickCallback callback)
    {
        for (int i = 0; i < list.Length; ++i) {
            Rect elementRect = GUILayoutUtility.GetRect(list[i], elementStyle);
            bool hover = elementRect.Contains(Event.current.mousePosition);
            /*
            if (hover && Event.current.type == EventType.MouseDown) {
                selected = i;
                Event.current.Use();
            } else if (hover && callback != null && Event.current.type == EventType.MouseUp && Event.current.clickCount == 2) {
                callback(i);
                Event.current.Use();
            } else if (Event.current.type == EventType.repaint) {
                elementStyle.Draw(elementRect, list[i], hover, false, i == selected, false);
            }
            */

            if (hover && Event.current.type == EventType.MouseDown && Event.current.clickCount == 1)
            {
                selected = i;
                Event.current.Use();
            }
            else if (hover && callback != null && Event.current.type == EventType.MouseDown && Event.current.clickCount == 2)
            {
                callback(i);
                Event.current.Use();
            }
            else if (Event.current.type == EventType.repaint)
            {
                elementStyle.Draw(elementRect, list[i], hover, false, i == selected, false);
            }
        }
        return selected;
    }
开发者ID:CianciuStyles,项目名称:angrybots-jaco,代码行数:34,代码来源:ImprovedSelectionList.cs

示例3: DoRepeatButton

 private static bool DoRepeatButton(Rect position, GUIContent content, GUIStyle style, FocusType focusType)
 {
   int controlId = GUIUtility.GetControlID(EditorGUIExt.repeatButtonHash, focusType, position);
   switch (Event.current.GetTypeForControl(controlId))
   {
     case EventType.MouseDown:
       if (position.Contains(Event.current.mousePosition))
       {
         GUIUtility.hotControl = controlId;
         Event.current.Use();
       }
       return false;
     case EventType.MouseUp:
       if (GUIUtility.hotControl != controlId)
         return false;
       GUIUtility.hotControl = 0;
       Event.current.Use();
       return position.Contains(Event.current.mousePosition);
     case EventType.Repaint:
       style.Draw(position, content, controlId);
       if (controlId == GUIUtility.hotControl)
         return position.Contains(Event.current.mousePosition);
       return false;
     default:
       return false;
   }
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:27,代码来源:EditorGUIExt.cs

示例4: OnPreviewGUI

		public virtual void OnPreviewGUI(Rect r, GUIStyle background)
		{
			if (Event.current.type == EventType.Repaint)
			{
				background.Draw(r, false, false, false, false);
			}
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:7,代码来源:ObjectPreview.cs

示例5: OnPreviewGUI

		public override void OnPreviewGUI(Rect r, GUIStyle background)
		{
			if (Event.current.type == EventType.Repaint)
			{
				background.Draw(r, false, false, false, false);
			}
			WebCamTexture webCamTexture = this.target as WebCamTexture;
			float num = Mathf.Min(Mathf.Min(r.width / (float)webCamTexture.width, r.height / (float)webCamTexture.height), 1f);
			Rect rect = new Rect(r.x, r.y, (float)webCamTexture.width * num, (float)webCamTexture.height * num);
			PreviewGUI.BeginScrollView(r, this.m_Pos, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
			GUI.DrawTexture(rect, webCamTexture, ScaleMode.StretchToFill, false);
			this.m_Pos = PreviewGUI.EndScrollView();
			if (webCamTexture.isPlaying)
			{
				GUIView.current.Repaint();
			}
			if (Application.isPlaying)
			{
				if (webCamTexture.isPlaying)
				{
					EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode");
				}
				else
				{
					EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode");
				}
			}
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:28,代码来源:WebCamTextureInspector.cs

示例6: DoRepeatButton

		private static bool DoRepeatButton(Rect position, GUIContent content, GUIStyle style, FocusType focusType)
		{
			int controlID = GUIUtility.GetControlID(EditorGUIExt.repeatButtonHash, focusType, position);
			EventType typeForControl = Event.current.GetTypeForControl(controlID);
			if (typeForControl == EventType.MouseDown)
			{
				if (position.Contains(Event.current.mousePosition))
				{
					GUIUtility.hotControl = controlID;
					Event.current.Use();
				}
				return false;
			}
			if (typeForControl != EventType.MouseUp)
			{
				if (typeForControl != EventType.Repaint)
				{
					return false;
				}
				style.Draw(position, content, controlID);
				return controlID == GUIUtility.hotControl && position.Contains(Event.current.mousePosition);
			}
			else
			{
				if (GUIUtility.hotControl == controlID)
				{
					GUIUtility.hotControl = 0;
					Event.current.Use();
					return position.Contains(Event.current.mousePosition);
				}
				return false;
			}
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:33,代码来源:EditorGUIExt.cs

示例7: Handle

	public static Vector2 Handle(GUIStyle style, int id, Vector2 position, bool allowKeyboardFocus)
	{
		int handleSize = (int)style.fixedWidth;
		Rect rect = new Rect(position.x - handleSize / 2, position.y - handleSize / 2, handleSize, handleSize);
		int controlID = id;
		
		switch (Event.current.GetTypeForControl(controlID))
		{
			case EventType.MouseDown:
			{
				if (rect.Contains(Event.current.mousePosition))
				{
					activePositionHandleId = id;
					if (allowKeyboardFocus) {
						GUIUtility.keyboardControl = controlID;
					}
					positionHandleOffset = Event.current.mousePosition - position;
					GUIUtility.hotControl = controlID;
					Event.current.Use();
				}
				break;
			}
			
			case EventType.MouseDrag:
			{
				if (GUIUtility.hotControl == controlID)				
				{
					position = Event.current.mousePosition - positionHandleOffset;
					Event.current.Use();					
				}
				break;
			}
			
			case EventType.MouseUp:
			{
				if (GUIUtility.hotControl == controlID)
				{
					activePositionHandleId = 0;
					position = Event.current.mousePosition - positionHandleOffset;
					GUIUtility.hotControl = 0;
					Event.current.Use();
				}
				break;
			}
			
			case EventType.Repaint:
			{
				bool selected = (GUIUtility.keyboardControl == controlID ||
								 GUIUtility.hotControl == controlID);
				style.Draw(rect, selected, false, false, false);
				break;
			}
		}
		
		return position;
	}
开发者ID:CoderBear,项目名称:AAUnity,代码行数:56,代码来源:tk2dGuiUtility.cs

示例8: DisplaySelectActionButton

 //http://answers.unity3d.com/questions/315724/loading-gui-in-middle-of-mouse-and-make-it-work-ra.html
 public bool DisplaySelectActionButton(Rect aRect, GUIContent aContent, GUIStyle aStyle)
 {
     Event e = Event.current;
     bool isOver = aRect.Contains(e.mousePosition);
     if (e.type == EventType.Repaint)
         aStyle.Draw(aRect, aContent, isOver, true, true, false);
     else if (isOver && e.type == EventType.MouseUp)
         return true;
     return false;
 }
开发者ID:amarathimi,项目名称:standard-weekend,代码行数:11,代码来源:ActionObjectController.cs

示例9: Splitter

	public static void Splitter(float thickness, GUIStyle splitterStyle) {
		Rect position = GUILayoutUtility.GetRect(GUIContent.none, splitterStyle, GUILayout.Height(thickness));
		
		if (Event.current.type == EventType.Repaint) {
			Color restoreColor = GUI.color;
			GUI.color = splitterColor;
			splitterStyle.Draw(position, false, false, false, false);
			GUI.color = restoreColor;
		}
	}
开发者ID:RuFengLau,项目名称:Unity3d.UI.Windows,代码行数:10,代码来源:CustomGUI.cs

示例10: DrawRetractedHeader

        public static void DrawRetractedHeader(Rect position, GUIContent label, GUIStyle backgroundStyle)
        {
            var rbg = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
            if (Event.current.type == EventType.Repaint && backgroundStyle != null)
                backgroundStyle.Draw(rbg, false, false, false, false);

            var rlbl = rbg;
            rlbl.xMin += 6f;
            rlbl.xMax -= 6f;
            rlbl.y += 1f;
            EditorGUI.LabelField(rlbl, label);
        }
开发者ID:XianWorld,项目名称:spacepuppy-unity-framework,代码行数:12,代码来源:ReorderableListHelper.cs

示例11: DrawCap

 private static void DrawCap(int controlID, Vector3 position, GUIStyle guiStyle)
 {
   if (Event.current.type != EventType.Repaint)
     return;
   Handles.BeginGUI();
   position = (Vector3) HandleUtility.WorldToGUIPoint(position);
   float fixedWidth = guiStyle.fixedWidth;
   float fixedHeight = guiStyle.fixedHeight;
   Rect position1 = new Rect(position.x - fixedWidth / 2f, position.y - fixedHeight / 2f, fixedWidth, fixedHeight);
   guiStyle.Draw(position1, GUIContent.none, controlID);
   Handles.EndGUI();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:12,代码来源:Joint2DEditor.cs

示例12: Splitter

 public static void Splitter(float thickness, GUIStyle splitterStyle)
 {
     Rect rect = GUILayoutUtility.GetRect(GUIContent.none, splitterStyle, new GUILayoutOption[]
     {
         GUILayout.Height(thickness)
     });
     if (Event.current.type == (EventType)7)
     {
         Color color = GUI.color;
         GUI.color = fiEditorGUILayout.splitterColor;
         splitterStyle.Draw(rect, false, false, false, false);
         GUI.color = color;
     }
 }
开发者ID:fuboss,项目名称:aiProject,代码行数:14,代码来源:fiEditorGUILayout.cs

示例13: PointSlider

 internal static Vector2 PointSlider(Vector2 pos, MouseCursor cursor, GUIStyle dragDot, GUIStyle dragDotActive)
 {
   int controlId = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard);
   Vector2 vector2 = (Vector2) Handles.matrix.MultiplyPoint((Vector3) pos);
   Rect rect = new Rect(vector2.x - dragDot.fixedWidth * 0.5f, vector2.y - dragDot.fixedHeight * 0.5f, dragDot.fixedWidth, dragDot.fixedHeight);
   if (Event.current.GetTypeForControl(controlId) == EventType.Repaint)
   {
     if (GUIUtility.hotControl == controlId)
       dragDotActive.Draw(rect, GUIContent.none, controlId);
     else
       dragDot.Draw(rect, GUIContent.none, controlId);
   }
   return SpriteEditorHandles.ScaleSlider(pos, cursor, rect);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:14,代码来源:SpriteEditorHandles.cs

示例14: BeginGroup

 public static void BeginGroup(Rect position, GUIContent content, GUIStyle style)
 {
     GUIUtility.CheckOnGUI();
     int controlID = GUIUtility.GetControlID(s_BeginGroupHash, FocusType.Passive);
     if ((content != GUIContent.none) || (style != GUIStyle.none))
     {
         if (Event.current.type == EventType.Repaint)
         {
             style.Draw(position, content, controlID);
         }
         else if (position.Contains(Event.current.mousePosition))
         {
             GUIUtility.mouseUsed = true;
         }
     }
     GUIClip.Push(position, Vector2.zero, Vector2.zero, false);
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:17,代码来源:GUI.cs

示例15: DoMaskField

 internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style, out int changedFlags, out bool changedToValue)
 {
   mask = MaskFieldGUI.MaskCallbackInfo.GetSelectedValueForControl(controlID, mask, out changedFlags, out changedToValue);
   List<int> intList = new List<int>();
   List<string> stringList = new List<string>() { "Nothing", "Everything" };
   for (int index = 0; index < flagNames.Length; ++index)
   {
     if ((mask & 1 << index) != 0)
       intList.Add(index + 2);
   }
   stringList.AddRange((IEnumerable<string>) flagNames);
   GUIContent content = EditorGUI.mixedValueContent;
   if (!EditorGUI.showMixedValue)
   {
     switch (intList.Count)
     {
       case 0:
         content = EditorGUIUtility.TempContent("Nothing");
         intList.Add(0);
         break;
       case 1:
         content = new GUIContent(stringList[intList[0]]);
         break;
       default:
         if (intList.Count >= flagNames.Length)
         {
           content = EditorGUIUtility.TempContent("Everything");
           intList.Add(1);
           mask = -1;
           break;
         }
         content = EditorGUIUtility.TempContent("Mixed ...");
         break;
     }
   }
   Event current = Event.current;
   if (current.type == EventType.Repaint)
     style.Draw(position, content, controlID, false);
   else if (current.type == EventType.MouseDown && position.Contains(current.mousePosition) || current.MainActionKeyForControl(controlID))
   {
     MaskFieldGUI.MaskCallbackInfo.m_Instance = new MaskFieldGUI.MaskCallbackInfo(controlID);
     current.Use();
     EditorUtility.DisplayCustomMenu(position, stringList.ToArray(), !EditorGUI.showMixedValue ? intList.ToArray() : new int[0], new EditorUtility.SelectMenuItemFunction(MaskFieldGUI.MaskCallbackInfo.m_Instance.SetMaskValueDelegate), (object) null);
   }
   return mask;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:46,代码来源:MaskFieldGUI.cs


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