UnityEngine.GUI.Toolbar(UnityEngine.Rect, int, UnityEngine.GUIContent[], UnityEngine.GUIStyle)

Here are the examples of the csharp api UnityEngine.GUI.Toolbar(UnityEngine.Rect, int, UnityEngine.GUIContent[], UnityEngine.GUIStyle) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

19 View Source File : VectorShapeEditor.cs
License : MIT License
Project Creator : ecurtz

protected void OnToolbarArea(Event guiEvent, Rect guiRect)
	{
		int activeButton = (int)activeTool;
		if (overrideAction != ActionType.None)
		{
			switch (overrideAction)
			{
				case ActionType.ViewPan:
				case ActionType.ViewZoom:
					activeButton = (int)ToolSet.View;
					break;
			}
		}

		Rect toolbarRect = new Rect(guiRect);
		toolbarRect.width = toolbarWidth * toolIcons.Length;
		int newButton = GUI.Toolbar(toolbarRect, activeButton, toolIcons);
		if (newButton != activeButton)
		{
			activeTool = (ToolSet)newButton;
		}

		Rect buttonRect = new Rect(guiRect);
		buttonRect.width = toolbarWidth;
		buttonRect.x = toolbarRect.xMax + toolbarPadding;
		if (GUI.Button(buttonRect, iconMoreTools))
		{
			GenericMenu toolMenu = new GenericMenu();

			toolMenu.AddItem(new GUIContent("Move Origin"), false, OnMoveOrigin);
			toolMenu.AddItem(new GUIContent("Change Scale"), false, OnChangeScale);

			toolMenu.AddSeparator("");

			toolMenu.AddItem(new GUIContent("Load SVG"), false, OnLoadSVG);
#if DXF_SUPPORT
			toolMenu.AddItem(new GUIContent("Load DXF"), false, OnLoadDXF);
#endif

			toolMenu.DropDown(buttonRect);
		}
	}

19 View Source File : VectorShapeEditor.cs
License : MIT License
Project Creator : ecurtz

protected void OnInfoAreaSelect(Event guiEvent, Rect guiRect)
	{
		Rect toolbarRect = new Rect(toolbarPadding, toolbarPadding, toolbarWidth * selectionIcons.Length, toolbarHeight);
		toolbarRect.position += guiRect.position;

		int activeButton = (int)activeSelect;

		int newButton = GUI.Toolbar(toolbarRect, activeButton, selectionIcons);
		if (newButton != activeButton)
		{
			activeSelect = (SelectionSet)newButton;
		}

		if (focusedShape != null)
		{
			shapeOutlineColor = focusedShape.colorOutline;
			shapeFillColor = focusedShape.colorFill;
		}
		Color currentOutline = shapeOutlineColor;
		Color currentFill = shapeFillColor;
		float currentPen = shapePenSize;

		Rect colorsRect = new Rect(toolbarRect.xMax, guiRect.position.y, guiRect.xMax - toolbarRect.xMax, guiRect.height);
		OnShapeColorArea(guiEvent, colorsRect);

		if (currentOutline != shapeOutlineColor)
		{
			foreach (VectorShape shape in selection)
			{
				shape.colorOutline = shapeOutlineColor;
				shape.Dirty = true;
			}
		}
		if (currentFill != shapeFillColor)
		{
			foreach (VectorShape shape in selection)
			{
				shape.colorFill = shapeFillColor;
				shape.Dirty = true;
			}
		}
		if (!Mathf.Approximately(currentPen, shapePenSize))
		{
			foreach (VectorShape shape in selection)
			{
				shape.penSize = shapePenSize;
				shape.Dirty = true;
			}
		}
	}

19 View Source File : VectorShapeEditor.cs
License : MIT License
Project Creator : ecurtz

protected void OnInfoAreaShape(Event guiEvent, Rect guiRect)
	{
		Rect toolbarRect = new Rect(toolbarPadding, toolbarPadding, toolbarWidth * shapeIcons.Length, toolbarHeight);
		toolbarRect.position += guiRect.position;

		int activeButton = (int)activeShape;

		int newButton = GUI.Toolbar(toolbarRect, activeButton, shapeIcons);
		if (newButton != activeButton)
		{
			activeShape = (ShapeSet)newButton;

			SetFocusedShape(null);
		}

		Rect colorsRect = new Rect(toolbarRect.xMax, guiRect.position.y, guiRect.xMax - toolbarRect.xMax, guiRect.height);
		OnShapeColorArea(guiEvent, colorsRect);
	}

19 View Source File : UPADrawer.cs
License : MIT License
Project Creator : liangxiegame

public static void DrawToolbar (Rect window, Vector2 mousePos) {

		// Draw toolbar bg
		EditorGUI.DrawRect ( new Rect (0,0, window.width, 40), toolbarColor );
		
		if ( GUI.Button (new Rect (5, 4, 50, 30), "New") ) {
			UPAImageCreationWindow.Init ();
		}
		if ( GUI.Button (new Rect (60, 4, 50, 30), "Open") ) {
			CurrentImg = UPASession.OpenImage ();
			if (CurrentImg == null)
				return;
		}
		if ( GUI.Button (new Rect (115, 4, 50, 30), "Export") ) {
			UPAExportWindow.Init(CurrentImg);
		}

		if (GUI.Button (new Rect (179, 6, 25, 25), "+")) {
			CurrentImg.gridSpacing *= 1.2f;
		}
		if (GUI.Button (new Rect (209, 6, 25, 25), "-")) {
			CurrentImg.gridSpacing *= 0.8f;
			CurrentImg.gridSpacing -= 2;
		}
		
		CurrentImg.selectedColor = EditorGUI.ColorField (new Rect (250, 7, 70, 25), CurrentImg.selectedColor);
		EditorGUI.DrawRect ( new Rect (303, 7, 20, 25), toolbarColor );
		//bgColor = EditorGUI.ColorField (new Rect (400, 4, 70, 25), bgColor);
		
		GUI.backgroundColor = Color.white;
		if (CurrentImg.tool == UPATool.PaintBrush)
			GUI.backgroundColor = new Color (0.7f, 0.7f, 0.7f);
		if (GUI.Button (new Rect (320, 4, 60, 30), "Paint")) {
			CurrentImg.tool = UPATool.PaintBrush;
		}
		GUI.backgroundColor = Color.white;
		if (CurrentImg.tool == UPATool.BoxBrush)
			GUI.backgroundColor = new Color (0.7f, 0.7f, 0.7f);
		if (GUI.Button (new Rect (450, 4, 60, 30), "Box Fill")) {
			EditorUtility.DisplayDialog(
				"In Development",
				"This feature is currently being developed.",
				"Get it done please");
			//tool = UPATool.BoxBrush;
		}
		GUI.backgroundColor = Color.white;
		if (CurrentImg.tool == UPATool.Eraser)
			GUI.backgroundColor = new Color (0.7f, 0.7f, 0.7f);
		if (GUI.Button (new Rect (385, 4, 60, 30), "Erase")) {
			CurrentImg.tool = UPATool.Eraser;
		}
		GUI.backgroundColor = Color.white;
		
		style.normal.textColor = new Color (0.7f, 0.7f, 0.7f);
		style.fontSize = 12;
		style.fontStyle = FontStyle.Normal;
		GUI.Label (new Rect (525, 11, 150, 30), "Use WASD to navigate.", style);
		
		if (GUI.Button (new Rect (684, 4, 55, 30), "Center")) {
			CurrentImg.gridOffsetX = 0;
			CurrentImg.gridOffsetY = 0;
		}
		
		CurrentImg.gridBGIndex = GUI.Toolbar (new Rect (743, 4, 130, 30), CurrentImg.gridBGIndex, gridBGStrings);
		
		if (CurrentImg.gridBGIndex == 0) {
			gridBGColor = Color.black;
		} else if (CurrentImg.gridBGIndex == 1) {
			gridBGColor = Color.white;
		} else {
			gridBGColor = Color.clear;
		}
		
		Vector2 pixelCoordinate = CurrentImg.GetReadablePixelCoordinate (mousePos);
		GUI.Label (new Rect (880, 11, 100, 30), "(" + (int)pixelCoordinate.x + "," + (int)pixelCoordinate.y + ")", style);

		if (CurrentImg.tool == UPATool.ColorPicker) {
			style.fontStyle = FontStyle.Bold;
			style.fontSize = 15;
			GUI.Label (new Rect (window.width/2f - 140, 60, 100, 30), "Click on a pixel to choose a color.", style);
		}
	}

19 View Source File : NetworkManagerEditor.cs
License : MIT License
Project Creator : Unity-Technologies

private void OnEnable()
        {
            m_NetworkPrefabsList = new ReorderableList(serializedObject, serializedObject.FindProperty(nameof(NetworkManager.NetworkConfig)).FindPropertyRelative(nameof(NetworkConfig.NetworkPrefabs)), true, true, true, true);
            m_NetworkPrefabsList.elementHeightCallback = index =>
            {
                var networkPrefab = m_NetworkPrefabsList.serializedProperty.GetArrayElementAtIndex(index);
                var networkOverrideProp = networkPrefab.FindPropertyRelative(nameof(NetworkPrefab.Override));
                var networkOverrideInt = networkOverrideProp.enumValueIndex;

                return 8 + (networkOverrideInt == 0 ? EditorGUIUtility.singleLineHeight : (EditorGUIUtility.singleLineHeight * 2) + 5);
            };
            m_NetworkPrefabsList.drawElementCallback = (rect, index, isActive, isFocused) =>
            {
                rect.y += 5;

                var networkPrefab = m_NetworkPrefabsList.serializedProperty.GetArrayElementAtIndex(index);
                var networkPrefabProp = networkPrefab.FindPropertyRelative(nameof(NetworkPrefab.Prefab));
                var networkSourceHashProp = networkPrefab.FindPropertyRelative(nameof(NetworkPrefab.SourceHashToOverride));
                var networkSourcePrefabProp = networkPrefab.FindPropertyRelative(nameof(NetworkPrefab.SourcePrefabToOverride));
                var networkTargetPrefabProp = networkPrefab.FindPropertyRelative(nameof(NetworkPrefab.OverridingTargetPrefab));
                var networkOverrideProp = networkPrefab.FindPropertyRelative(nameof(NetworkPrefab.Override));
                var networkOverrideInt = networkOverrideProp.enumValueIndex;
                var networkOverrideEnum = (NetworkPrefabOverride)networkOverrideInt;
                EditorGUI.LabelField(new Rect(rect.x + rect.width - 70, rect.y, 60, EditorGUIUtility.singleLineHeight), "Override");
                if (networkOverrideEnum == NetworkPrefabOverride.None)
                {
                    if (EditorGUI.Toggle(new Rect(rect.x + rect.width - 15, rect.y, 10, EditorGUIUtility.singleLineHeight), false))
                    {
                        networkOverrideProp.enumValueIndex = (int)NetworkPrefabOverride.Prefab;
                    }
                }
                else
                {
                    if (!EditorGUI.Toggle(new Rect(rect.x + rect.width - 15, rect.y, 10, EditorGUIUtility.singleLineHeight), true))
                    {
                        networkOverrideProp.enumValueIndex = 0;
                        networkOverrideEnum = NetworkPrefabOverride.None;
                    }
                }

                if (networkOverrideEnum == NetworkPrefabOverride.None)
                {
                    EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width - 80, EditorGUIUtility.singleLineHeight), networkPrefabProp, GUIContent.none);
                }
                else
                {
                    networkOverrideProp.enumValueIndex = GUI.Toolbar(new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight), networkOverrideInt - 1, new[] { "Prefab", "Hash" }) + 1;

                    if (networkOverrideEnum == NetworkPrefabOverride.Prefab)
                    {
                        EditorGUI.PropertyField(new Rect(rect.x + 110, rect.y, rect.width - 190, EditorGUIUtility.singleLineHeight), networkSourcePrefabProp, GUIContent.none);
                    }
                    else
                    {
                        EditorGUI.PropertyField(new Rect(rect.x + 110, rect.y, rect.width - 190, EditorGUIUtility.singleLineHeight), networkSourceHashProp, GUIContent.none);
                    }

                    rect.y += EditorGUIUtility.singleLineHeight + 5;

                    EditorGUI.LabelField(new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight), "Overriding Prefab");
                    EditorGUI.PropertyField(new Rect(rect.x + 110, rect.y, rect.width - 110, EditorGUIUtility.singleLineHeight), networkTargetPrefabProp, GUIContent.none);
                }
            };
            m_NetworkPrefabsList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "NetworkPrefabs");
        }