UnityEngine.GUI.Toggle(UnityEngine.Rect, bool, UnityEngine.GUIContent, UnityEngine.GUIStyle)

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

50 Examples 7

19 View Source File : CoreEditorUtils.cs
License : MIT License
Project Creator : TheSlippyPenguin

public static bool DrawSubHeaderFoldout(GUIContent replacedle, bool state, bool isBoxed = false, Func<bool> isAdvanced = null, Action switchAdvanced = null)
        {
            const float height = 17f;
            var backgroundRect = GUILayoutUtility.GetRect(1f, height);

            var labelRect = backgroundRect;
            labelRect.xMin += 16f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.x += 15 * EditorGUI.indentLevel; //GUI do not handle indent. Handle it here
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;

            var advancedRect = new Rect();
            if (isAdvanced != null)
            {
                advancedRect = backgroundRect;
                advancedRect.x += advancedRect.width - 16 - 1;
                advancedRect.y -= 2;
                advancedRect.height = 16;
                advancedRect.width = 16;

                GUIStyle styleAdvanced = new GUIStyle(GUI.skin.toggle);
                styleAdvanced.normal.background = isAdvanced()
                    ? Resources.Load<Texture2D>("Advanced_Pressed_mini")
                    : Resources.Load<Texture2D>("Advanced_UnPressed_mini");
                styleAdvanced.onActive.background = styleAdvanced.normal.background;
                styleAdvanced.onFocused.background = styleAdvanced.normal.background;
                styleAdvanced.onNormal.background = styleAdvanced.normal.background;
                styleAdvanced.onHover.background = styleAdvanced.normal.background;
                styleAdvanced.active.background = styleAdvanced.normal.background;
                styleAdvanced.focused.background = styleAdvanced.normal.background;
                styleAdvanced.hover.background = styleAdvanced.normal.background;
                EditorGUI.BeginChangeCheck();
                GUI.Toggle(advancedRect, isAdvanced(), GUIContent.none, styleAdvanced);
                if (EditorGUI.EndChangeCheck() && switchAdvanced != null)
                {
                    switchAdvanced();
                }
            }

            // Background rect should be full-width
            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            if (isBoxed)
            {
                labelRect.xMin += 5;
                foldoutRect.xMin += 5;
                backgroundRect.xMin = EditorGUIUtility.singleLineHeight;
                backgroundRect.width -= 3;
            }

            // replacedle
            EditorGUI.LabelField(labelRect, replacedle, EditorStyles.boldLabel);

            // Active checkbox
            state = GUI.Toggle(foldoutRect, state, GUIContent.none, EditorStyles.foldout);

            var e = Event.current;
            if (e.type == EventType.MouseDown && backgroundRect.Contains(e.mousePosition) && !advancedRect.Contains(e.mousePosition) && e.button == 0)
            {
                state = !state;
                e.Use();
            }

            return state;
        }

19 View Source File : StyleTab.cs
License : MIT License
Project Creator : WooshiiDev

private void DrawStyleElements(Rect rect, int index, bool isActive, bool isFocused)
        {

            rect.x += 3f;
            rect.width -= 3f;

            if (index >= serializedStyles.arraySize)
            {
                return;
            }

            SerializedProperty style = serializedStyles.GetArrayElementAtIndex (index);
            SerializedProperty nameProp = style.FindPropertyRelative ("name");

            Rect removeRect = rect;
            removeRect.x = removeRect.width + 6f;
            removeRect.width = 48f;
            removeRect.height = 18f;
            if (GUI.Button (removeRect, "Delete", EditorStyles.centeredGreyMiniLabel))
            {
                serializedStyles.DeleteArrayElementAtIndex (index);
                serializedSettings.ApplyModifiedProperties ();
                serializedSettings.Update ();
                return;
            }

            rect.y--;

            Rect foldoutRect = GetFoldoutRect(rect);
            Rect labelRect = GetStyleLabelRect(rect);
            Rect styleRect = GetStyleRect(rect);

            EditorGUI.BeginChangeCheck ();
            {
                HierarchyGUI.DrawHierarchyStyle (settings.styleData[index], styleRect, labelRect, nameProp.stringValue, false);

                // Use GUI over EditorGUI due to overlapping on draggable
                style.isExpanded = GUI.Toggle (foldoutRect, style.isExpanded, "", EditorStyles.foldout);

                Rect propertyRect = GetStylePropertyRect (rect);

                if (style.isExpanded)
                {
                    Rect box = propertyRect;
                    box.height -= 18f;
                    box.x = styleRect.x;
                    box.width = styleRect.width;
                    box.y -= 3f;

                    GUI.Box (box, "");

                    var customDraws = new Dictionary<string, Action<Rect, SerializedProperty>> ()
                    {
                        { "modes", DrawModes }
                    };

                    SerializedPropertyUtility.DrawChildrenProperties (propertyRect, style, style.isExpanded, customDraws);
                }
            }
            if (EditorGUI.EndChangeCheck ())
            {
                serializedSettings.ApplyModifiedProperties ();
                serializedSettings.Update ();

                settings.styleData[index].UpdateStyle (EditorGUIUtility.isProSkin);
            }
        }

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

public static void DrawLayerPanel (Rect window) {
		
		style.imagePosition = ImagePosition.ImageAbove;
		
		int from = 0;
		int to = 0;

		if (CurrentImg == null)
			return;

		for (int i = 0; i < CurrentImg.layers.Count; i++) {
			GUI.backgroundColor = Color.white;
			if (i == CurrentImg.selectedLayer) {
				GUI.backgroundColor = new Color (0.7f, 0.7f, 0.7f);
			}

			UPALayer tempLayer = CurrentImg.layers[i];
			if (GUI.Button (new Rect (12, window.height - 60 - i * 36, 65, 33), "")) {
				CurrentImg.selectedLayer = i;
			}

			GUI.backgroundColor = Color.white;
			GUI.Label (new Rect (15, window.height - 52 - i * 36, 90, 30), tempLayer.name);

			bool layerEnabled = tempLayer.enabled;
			tempLayer.enabled = GUI.Toggle (new Rect (80, window.height - 61 - i * 36, 15, 15), tempLayer.enabled, "");
			if (tempLayer.enabled != layerEnabled)
				tempLayer.parentImg.dirty = true;

			if (removeLayerIcon == null)
				removeLayerIcon = (Texture2D)Resources.Load ("UI/CrossWhite");

			if (tempLayer.locked) {
				if (GUI.Button (new Rect (80, window.height - 43 - i * 36, 15, 15), Resources.Load("UI/locked") as Texture2D,style)) {
					tempLayer.locked = false;
				}
			} else {
				if (GUI.Button (new Rect (80, window.height - 43 - i * 36, 15, 15), Resources.Load("UI/unlocked") as Texture2D,style)) {
					tempLayer.locked = true;
				}
			}

			
			if (i + 1 < CurrentImg.layers.Count) {
				if (GUI.Button (new Rect (97, window.height - 60  - i * 36, 22, 16), "+")) {
					from = i;
					to = i + 1;
				}
			}
			
			if (i > 0) {
				if (GUI.Button (new Rect (97, window.height - 44 - i * 36, 22, 16), "-")) {
					from = i;
					to = i - 1;
				}
			}

			CurrentImg.layers[i] = tempLayer;
		}

		if (from != 0 || to != 0) {
			CurrentImg.ChangeLayerPosition (from, to);
		}

		GUIStyle smallButon = new GUIStyle();
		smallButon.fontSize = 8;
		smallButon.alignment = TextAnchor.MiddleCenter;
		smallButon.normal.background = Resources.Load ("Background") as Texture2D;

		if (GUI.Button (new Rect (12, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/add") as Texture, "Add Layer"), smallButon)) {
			CurrentImg.AddLayer ();
		}

		if (CurrentImg.layerCount == 1)
		{
			GUI.contentColor = new Color(0.7f, 0.7f, 0.7f);
		}
		if (GUI.Button(new Rect(12 + 20, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/delete") as Texture, "Delete Layer"), smallButon))
		{
			if (CurrentImg.layers.Count > 1) {
				bool delete = EditorUtility.DisplayDialog(
					"Delete Layer",
					"Do you want to remove " + CurrentImg.layers[CurrentImg.selectedLayer].name + "?",
					"Delete",
					"Cancel");
				
				if (delete) {
					CurrentImg.RemoveLayerAt(CurrentImg.selectedLayer);
				}
			}
		}
		GUI.contentColor = Color.white;

		if (GUI.Button(new Rect(12 + 20 * 2, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/import") as Texture, "Import Image"), smallButon))
		{
			string path = EditorUtility.OpenFilePanel(
				"Find an Image (.jpg | .png)",
				"/",
				"Image Files;*.jpg;*.png");
			
			if (path.Length != 0) {
				// Load Texture from file
				Texture2D tex = null;
				byte[] fileData;
				if (File.Exists(path))     {
					fileData = File.ReadAllBytes(path);
					tex = new Texture2D(2, 2);
					tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.
				}
				// Create a new Image with textures dimensions
				CurrentImg.AddLayer();
				// Set pixel colors
				UPALayer layer = CurrentImg.layers[CurrentImg.layers.Count - 1];
				for (int x = 0; x < CurrentImg.width; x++) {
					for (int y = 0; y < CurrentImg.height; y++) {
						layer.map[x + y * CurrentImg.width] = tex.GetPixel(x, CurrentImg.height - 1 - y);
					}
				}
				layer.LoadTexFromMap();
			}
		}

		if (GUI.Button(new Rect(12 + 20 * 3, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/duplicate") as Texture, "Duplicate Layer"), smallButon))
		{
			CurrentImg.layers.Add(new UPALayer(CurrentImg.layers[CurrentImg.selectedLayer]));
		}

		if (CurrentImg.selectedLayer == 0)
		{
			GUI.contentColor = new Color(0.7f, 0.7f, 0.7f);
		}
		if (GUI.Button(new Rect(12 + 20 * 4, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/merge") as Texture, "Merge Layer Down"), smallButon))
		{
			if (CurrentImg.selectedLayer > 0)
			{
				UPALayer upper = CurrentImg.layers[CurrentImg.selectedLayer];
				UPALayer lower = CurrentImg.layers[CurrentImg.selectedLayer - 1];
				lower.tex = UPABlendModes.Blend(lower.tex, lower.opacity, upper.tex, upper.opacity, upper.mode);
				for (int x = 0; x < lower.tex.width; x++)
				{
					for (int y = 0; y < lower.tex.height; y++)
					{
						lower.map[x + y * lower.tex.width] = lower.tex.GetPixel(x, lower.tex.height - 1 - y);
					}
				}
				CurrentImg.RemoveLayerAt(CurrentImg.selectedLayer);
			}
		}
		GUI.contentColor = Color.white;

		//if (GUI.Button (new Rect (12 + 18 * 4, window.height - 18, 16, 16),  Resources.Load("UI/up") as Texture2D, style)) {
		//	CurrentImg.AddLayer ();
		//}

		//if (GUI.Button (new Rect (12 + 18 * 5, window.height - 18, 16, 16),  Resources.Load("UI/down") as Texture2D, style)) {
		//	CurrentImg.AddLayer ();
		//}

		if (GUI.Button(new Rect(12 + 20 * 5, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/edit") as Texture, "Layer Options"), smallButon))
		{
			UPALayerSettings.Init(CurrentImg.layers[CurrentImg.selectedLayer]);
		}

		// Draw layer button tooltips
		if (GUI.tooltip != "")
			GUI.Box(new Rect(12, window.height - 43, 120, 20), GUI.tooltip);

		//CurrentImg.selectedLayer = GUI.Toolbar (new Rect (4, window.height - 200, 90, 30), CurrentImg.selectedLayer, layerNames);
	}

19 View Source File : Menu.cs
License : MIT License
Project Creator : ThePotato97

private static void RoomGUI()
        {
            if (!PhotonNetwork.InRoom)
            {
                GUI.Label(new Rect(720f, 0f, 200f, 20f), "Custom Room Creator:");
                serverName = GUI.TextArea(new Rect(720f, 25f, 200f, 20f), serverName);
                serverSlots = GUI.HorizontalSlider(new Rect(720f, 50f, 200f, 20f), (float)((int)serverSlots), 4f, 90f);
                GUI.Label(new Rect(720f, 65f, 200f, 20f), "Slots: " + ((int)serverSlots).ToString());
                if (GUI.Toggle(new Rect(720f, 80f, 200f, 20f), isPrivateServer, "Private Room") != isPrivateServer)
                {
                    isPrivateServer = !isPrivateServer;
                }
                if (GUI.Button(new Rect(720f, 105f, 200f, 20f), "Create Custom Room"))
                {
                    if (isPrivateServer)
                    {
                        PlayerPrefs.SetInt("isPublicServer", 0);
                        RoomOptions roomOptions = new RoomOptions
                        {
                            IsOpen = true,
                            IsVisible = false,
                            MaxPlayers = Convert.ToByte((int)serverSlots),
                            PlayerTtl = 2000
                        };
                        PhotonNetwork.CreateRoom(UnityEngine.Random.Range(0, 999999).ToString("000000"), roomOptions, TypedLobby.Default);
                    }
                    if (!isPrivateServer)
                    {
                        PlayerPrefs.SetInt("isPublicServer", 1);
                        RoomOptions roomOptions2 = new RoomOptions
                        {
                            IsOpen = true,
                            IsVisible = true,
                            MaxPlayers = Convert.ToByte((int)serverSlots),
                            PlayerTtl = 2000
                        };
                        PhotonNetwork.CreateRoom(serverName + "#" + UnityEngine.Random.Range(0, 999999).ToString("000000"), roomOptions2, TypedLobby.Default);
                    }
                }
            }
        }

19 View Source File : AnimationTrackDrawer.cs
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski

public override void DrawTrackHeaderButton(Rect rect, WindowState state)
        {
            var animTrack = track as AnimationTrack;
            if (animTrack == null) return;

            var style = DirectorStyles.Instance.trackAvatarMaskButton;
            var tooltip = animTrack.applyAvatarMask ? Styles.AvatarMaskInactiveTooltip : Styles.AvatarMaskActiveTooltip;

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                var toggle = GUI.Toggle(rect, animTrack.applyAvatarMask, tooltip, style);
                if (check.changed)
                {
                    animTrack.applyAvatarMask = toggle;
                    if (state != null)
                        state.rebuildGraph = true;
                }
            }
        }

19 View Source File : MaterialChangerEditor.cs
License : MIT License
Project Creator : Interactml

void HeaderCallbackDelegate(Rect rect)
        {
            Rect R_0 = new Rect(rect.x, rect.y, 15, EditorGUIUtility.singleLineHeight);
            Rect R_01 = new Rect(rect.x+14, rect.y, 35, EditorGUIUtility.singleLineHeight);
            Rect R_1 = new Rect(rect.x + 14 + 25, rect.y, (rect.width - 10) / 2, EditorGUIUtility.singleLineHeight);
            Rect R_2 = new Rect(rect.x + 35 +((rect.width - 30) / 2), rect.y, rect.width - ((rect.width) / 2) - 25, EditorGUIUtility.singleLineHeight);
            M.showMeshesList = EditorGUI.ToggleLeft(R_0, new GUIContent("", "Show the Material Items when Selected"), M.showMeshesList);

            EditorGUI.LabelField(R_01,new GUIContent (" #","Index"), EditorStyles.miniLabel);
            EditorGUI.LabelField(R_1, "Material Items", EditorStyles.miniLabel);
            EditorGUI.LabelField(R_2, "CURRENT", EditorStyles.centeredGreyMiniLabel);
            Rect R_3 = new Rect(rect.width+5, rect.y+1, 20, EditorGUIUtility.singleLineHeight-2);
            M.random =  GUI.Toggle(R_3, M.random, new GUIContent( "R","On Start replacedigns a Random Material"), EditorStyles.miniButton);
        }

19 View Source File : SelectEnvToSpawn.cs
License : Apache License 2.0
Project Creator : Unity-Technologies

void ShowGUI(int windowID)
        {
            GUI.skin.toggle.fontSize = fontSize;
            Rect rect = new Rect(5, fontSize + 4, 400, fontSize + 4);
            for (int i = 0; i < envIds.Length; i++)
            {
                bool active = envIdIdex == i;
                GUI.SetNextControlName(envIds[i]);
                if (GUI.Toggle(rect, active, envIds[i]))
                    envIdIdex = i;
                rect.y += rect.height;
            }

            rect.x = 400 - 90;
            rect.width = 75;
            rect.height = 30;
            GUI.SetNextControlName("GO");
            if (GUI.Button(new Rect(rect), "GO"))
                Go();
            GUI.FocusControl(agentSpawner.spawnableEnvDefinitions[envIdIdex].envId);
        }

19 View Source File : UnityPoolDrawer.cs
License : GNU General Public License v3.0
Project Creator : grygus

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty prefabProperty = property.FindPropertyRelative("Prefab");
            SerializedProperty nameProperty = property.FindPropertyRelative("Name");
            SerializedProperty sizeProperty = property.FindPropertyRelative("Size");
            SerializedProperty allowExpandProperty = property.FindPropertyRelative("AllowExpand");
            SerializedProperty allowRecycleProperty = property.FindPropertyRelative("AllowRecycle");

            GUIStyle buttonStyle = new GUIStyle(EditorStyles.toolbarButton);
            var headerPosition = new Rect(position.x, position.y, position.width, 20);
            GUI.Box(headerPosition, "", EditorStyles.toolbar);

            var layoutNavigator = new RectPositionWrapper(position);


            GUI.Label(layoutNavigator.ReserveDrawSpace(0.25f), string.Empty);

            allowExpandProperty.boolValue = GUI.Toggle(layoutNavigator.ReserveDrawSpace(0.25f), allowExpandProperty.boolValue, "Expand", buttonStyle);
            allowRecycleProperty.boolValue = GUI.Toggle(layoutNavigator.ReserveDrawSpace(0.25f), allowRecycleProperty.boolValue, "Recycle",
                buttonStyle);
            if (GUI.Button(layoutNavigator.ReserveDrawSpace(0.25f), "X",buttonStyle))
            {
                Delete(property);
            }
            property.isExpanded = EditorGUI.Foldout(headerPosition, property.isExpanded, nameProperty.stringValue);

            if (property.isExpanded)
            {

                GUI.Box(position, "", GUI.skin.box);
                layoutNavigator.MoveNextLine();
                layoutNavigator.Span();
                layoutNavigator.Span();
                EditorGUI.PropertyField(layoutNavigator.ReserveDrawSpace(1f), sizeProperty);
                layoutNavigator.MoveNextLine();
                EditorGUI.BeginChangeCheck();
                EditorGUI.PropertyField(layoutNavigator.ReserveDrawSpace(1f), prefabProperty);
                if (EditorGUI.EndChangeCheck())
                {
                    if (prefabProperty.objectReferenceValue)
                        nameProperty.stringValue = prefabProperty.objectReferenceValue.name;
                }
            }
        }

19 View Source File : TimeControl.cs
License : MIT License
Project Creator : XINCGer

public void DoTimeControl(Rect rect)
        {
            if (s_Styles == null)
                s_Styles = new Styles();

            var evt = Event.current;
            int id = EditorGUIUtility.GetControlID(kScrubberIDHash, FocusType.Keyboard);

            // Play/Pause Button + Scrubber
            Rect timelineRect = rect;
            timelineRect.height = kScrubberHeight;
            // Only Scrubber
            Rect scrubberRect = timelineRect;
            scrubberRect.xMin += kPlayButtonWidth;

            // Handle Input
            switch (evt.GetTypeForControl(id))
            {
                case EventType.MouseDown:
                    if (rect.Contains(evt.mousePosition))
                    {
                        EditorGUIUtility.keyboardControl = id;
                    }
                    if (scrubberRect.Contains(evt.mousePosition))
                    {
                        EditorGUIUtility.SetWantsMouseJumping(1);
                        EditorGUIUtility.hotControl = id;
                        m_MouseDrag = evt.mousePosition.x - scrubberRect.xMin;
                        nextCurrentTime = (m_MouseDrag * (stopTime - startTime) / scrubberRect.width + startTime);
                        m_WrapForwardDrag = false;
                        evt.Use();
                    }
                    break;
                case EventType.MouseDrag:
                    if (EditorGUIUtility.hotControl == id)
                    {
                        m_MouseDrag += evt.delta.x * playbackSpeed;
                        // We want to not wrap if we immediately drag to the beginning, but we do want to wrap if we drag past the end.
                        if (loop && ((m_MouseDrag < 0.0f && m_WrapForwardDrag) || (m_MouseDrag > scrubberRect.width)))
                        {
                            // scrubing out of range was generating a big deltaTime in wrong time direction
                            // this new code prevent this and it is compliant with new and more robust v5.0 root motion looping of animation clip
                            if (m_MouseDrag > scrubberRect.width)
                            {
                                currentTime -= (stopTime - startTime);
                                OnPlayEnd?.Invoke();
                            }
                            else if (m_MouseDrag < 0)
                            {
                                currentTime += (stopTime - startTime);
                            }

                            m_WrapForwardDrag = true;
                            m_MouseDrag = Mathf.Repeat(m_MouseDrag, scrubberRect.width);
                        }
                        nextCurrentTime = (Mathf.Clamp(m_MouseDrag, 0.0f, scrubberRect.width) * (stopTime - startTime) / scrubberRect.width + startTime);
                        evt.Use();
                    }
                    break;
                case EventType.MouseUp:
                    if (EditorGUIUtility.hotControl == id)
                    {
                        EditorGUIUtility.SetWantsMouseJumping(0);
                        EditorGUIUtility.hotControl = 0;
                        evt.Use();
                    }
                    break;
                case EventType.KeyDown:
                    if (EditorGUIUtility.keyboardControl == id)
                    {
                        // TODO: loop?
                        if (evt.keyCode == KeyCode.LeftArrow)
                        {
                            if (currentTime - startTime > kStepTime)
                                deltaTime = -kStepTime;
                            evt.Use();
                        }
                        if (evt.keyCode == KeyCode.RightArrow)
                        {
                            if (stopTime - currentTime > kStepTime)
                                deltaTime = kStepTime;
                            evt.Use();
                        }
                    }
                    break;
            }

            // background
            GUI.Box(timelineRect, GUIContent.none, s_Styles.timeScrubber);

            // Play/Pause Button
            playing = GUI.Toggle(timelineRect, playing, playing ? s_Styles.pauseIcon : s_Styles.playIcon, s_Styles.playButton);

            // Current time indicator
            float normalizedPosition = Mathf.Lerp(scrubberRect.x, scrubberRect.xMax, normalizedTime);
            DrawPlayhead(normalizedPosition, scrubberRect.yMin, scrubberRect.yMax, 2f, (EditorGUIUtility.keyboardControl == id) ? 1f : 0.5f);
        }

19 View Source File : EditorUtilities.cs
License : MIT License
Project Creator : huailiang

public static void DrawOverrideCheckbox(Rect rect, SerializedProperty property)
        {
            property.boolValue = GUI.Toggle(rect, property.boolValue, GetContent("|Override this setting for this volume."), Styling.smallTickbox);
        }

19 View Source File : DitherEditor.cs
License : MIT License
Project Creator : Relfos

void OnGUI()
    {
        int minSteps, maxSteps;

        switch (mode)
        {            
            case 1: minSteps = 3; maxSteps = 5; break;
            case 2: minSteps = 3; maxSteps = 9; break;
            case 3: minSteps = 3; maxSteps = 17; break;
            default: minSteps = 3; maxSteps = 17; break;
        }

        int row2 = 250;
        GUI.Label(new Rect(row2, 25, 100, 20), "Colors");
        colorCount = (int)GUI.HorizontalSlider(new Rect(row2, 50, 100, 25), colorCount, 2, maxColors);

        if (mode>0)
        {
            GUI.Label(new Rect(row2, 75, 100, 20), "Steps");
            steps = (int)GUI.HorizontalSlider(new Rect(row2, 100, 100, 25), steps, minSteps, maxSteps);
        }

        showGrad = GUI.Toggle(new Rect(row2, 125, 100, 25), showGrad, "View Gradient");

        int row3 = 425;

        if (ditherKind == DitherKind.Linear)
        {
            if (mode >0 )
            {
                rotatePat = GUI.Toggle(new Rect(row3, 125, 100, 25), rotatePat, "Rotate Pattern");
            }
        }
        else
        {
            rotatePat = false;
        }

        switch (ditherKind)
        {
            case DitherKind.Linear:
                {
                    GUI.Label(new Rect(row3, 25, 100, 20), "Angle");
                    angle = (int)GUI.HorizontalSlider(new Rect(row3, 50, 200, 25), angle, 0, 360);

                    string tempAngle = GUI.TextField(new Rect(row3 + 210, 50, 100, 20), angle.ToString());
                    int.TryParse(tempAngle, out angle);

                    if (angle > 360) { angle = 360; }
                    if (angle < 0) { angle = 0; }
                    break;
                }

            case DitherKind.Radial:
                {
                    GUI.Label(new Rect(row3, 25, 100, 20), "Offset X");
                    radX = GUI.HorizontalSlider(new Rect(row3, 50, 100, 25), radX, -0.5f, 0.5f);
                    GUI.Label(new Rect(row3+110, 25, 100, 20), "Offset Y");
                    radY = GUI.HorizontalSlider(new Rect(row3 + 110, 50, 100, 25), radY, -0.5f, 0.5f);
                    GUI.Label(new Rect(row3 + 220, 25, 100, 20), "Scale");
                    radScale = GUI.HorizontalSlider(new Rect(row3 + 220, 50, 100, 25), radScale, 0.25f, 1);

                    break;
                }

            case DitherKind.Custom:
                {
                    GUI.Label(new Rect(row3, 25, 100, 20), "Greyscale Source");
                    if (GUI.Button(new Rect(row3, 50, 150, 20), "Paste From Clipboard"))
                    {
                        int width, height;
                        var pixels = Clipboard.ReadPixels(out width, out height);
                        if (pixels != null)
                        {
                            canvreplacedize = Math.Max(width, height);
                            customDitherSource = new float[canvreplacedize * canvreplacedize];

                            int padX = (canvreplacedize - width) / 2;
                            int padY = (canvreplacedize - height) / 2;

                            for (int j = 0; j < canvreplacedize; j++)
                            {
                                for (int i = 0; i < canvreplacedize; i++)
                                {
                                    float dist;
                                    if (i<width && j<height)
                                    {
                                        var pixel = pixels[i + j * width];
                                        if (pixel.r == pixel.g && pixel.r == pixel.b)
                                        {
                                            dist = pixel.r / 255.0f;
                                        }
                                        else
                                        {
                                            dist = (0.3f * pixel.r + 0.59f * pixel.g + 0.11f * pixel.b) / 255.0f;
                                        }                                        
                                    }
                                    else
                                    {
                                        dist = 0;
                                    }

                                    int targetOfs = i + padX + (j + padY) * canvreplacedize;
                                    if (targetOfs<customDitherSource.Length)
                                    {
                                        customDitherSource[targetOfs] = dist;
                                    }                                    
                                }
                            }
                        }
                    }

                    break;
                }
        }

        GUI.Label(new Rect(row3, 75, 100, 20), "Pattern");
        mode = (int)GUI.HorizontalSlider(new Rect(row3, 100, 100, 25), mode, 0, patternNames.Length-1);
        mode = patternComboBox.Show(new Rect(row3 + 115, 95, 100, 20), mode, patternContentList);
        //GUI.Label(new Rect(row3 + 120, 90, 100, 20), patternNames[mode]);

        //ditherKind = (DitherKind) GUI.Toolbar(new Rect(row3 + 220, 90, 160, 20), (int)ditherKind, ditherToolbar);
        ditherKind = (DitherKind) ditherModeCombobox.Show(new Rect(row3 + 220, 95, 100, 20), (int)ditherKind, ditherModeContentList);

        int row4 = Screen.width - 225;

        int lY = 350;
        GUI.Label(new Rect(row4, lY + 10, 220, 20), "FREE dithering tool");
        GUI.Label(new Rect(row4, lY + 25, 220, 20), "Made by LUNAR LABS");
        GUI.Label(new Rect(row4, lY + 50, 220, 20), "Contact me for feedback / ideas!");

        GUI.Label(new Rect(row4, lY + 75, 220, 20), "Links:");
        if (GUI.Button(new Rect(row4, lY + 100, 150, 20), "Website"))
        {
            Application.OpenURL("http://lunarlabs.pt");
        }

        if (GUI.Button(new Rect(row4, lY + 125, 150, 20), "Twitter"))
        {
            Application.OpenURL("https://twitter.com/onihunters");
        }

        if (GUI.Button(new Rect(row4, lY + 150, 150, 20), "Facebook"))
        {
            Application.OpenURL("https://www.facebook.com/lunarlabspt/");
        }

        if (GUI.Button(new Rect(row4, lY + 175, 150, 20), "Tumblr"))
        {
            Application.OpenURL("http://onihunters.tumblr.com/");
        }

        if (GUI.Button(new Rect(row4, lY + 200, 150, 20), "itch.io"))
        {
            Application.OpenURL("https://lunarlabs.itch.io");
        }

        if (GUI.Button(new Rect(row4, lY + 225, 150, 20), "replacedet Store"))
        {
            Application.OpenURL("https://www.replacedetstore.unity3d.com/en/#!/search/page=1/sortby=popularity/query=publisher:6001");
        }


        if (GUI.Button(new Rect(20, Screen.height - 30, 150, 20), "Exit"))
        {
            Application.Quit();
        }

        int row1 = 25;

        int y = 25;

        for (int i=0; i<colorCount; i++)
        {
            GUIDrawRect(new Rect(row1 - 22, y, 20, 20), colors[i].color);
            //GUI.Label(new Rect(row1, y, 100, 20), "Color "+(i+1).ToString());

            colors[i].hex = GUI.TextField(new Rect(row1, y, 80, 20), colors[i].hex);

            if (i<colorCount-1 && !equalize)
            {
                colors[i].percentage = GUI.HorizontalSlider(new Rect(row1 + 90, 5 + y, 80, 20), colors[i].percentage, 0, 1);
            }

            y += 25;
        }

        equalize = GUI.Toggle(new Rect(row1 - 20, y, 150, 25), equalize, "Equalize percentages");
        y += 25;

        GUI.Label(new Rect(row1 - 20, y, 100, 20), "Palette");
        SelectPalette(paletteCombobox.Show(new Rect(row1 + 60, y, 100, 20), currentPaletteIndex, paletteNames));
        y += 25;

        GUI.Label(new Rect(row2, Screen.height - 100, 100, 20), "Canvas size");
        tempCanvreplacedize = GUI.TextField(new Rect(row2, Screen.height - 75, 100, 20), tempCanvreplacedize);

        if (GUI.Button(new Rect(row2 + 105, Screen.height - 75, 100, 20), "Apply"))
        {
            int.TryParse(tempCanvreplacedize, out canvreplacedize);
            if (canvreplacedize>512)
            {
                canvreplacedize = 512;
            }
        }

        int ppx = row3 + 175;
        
        exportPath = GUI.TextField(new Rect(ppx, Screen.height - 35, Screen.width - (ppx+20), 25), exportPath);
        if (GUI.Button(new Rect(row3, Screen.height - 35, 150, 25), "Export to File"))
        {
            try
            {
                var bytes = outputTexture.EncodeToPNG();
                File.WriteAllBytes(exportPath, bytes);

                PlayerPrefs.SetString("path", exportPath);
                PlayerPrefs.Save();

                var url = "file://" + exportPath.Replace('\\', '/');
                Debug.Log(url);
                Application.OpenURL(url);
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }
        }

        if (Clipboard.isClipboardSupported(Clipboard.Format.Image) && GUI.Button(new Rect(row2, Screen.height - 35, 150, 25), "Export to Clipboard"))
        {
            //Debug.Log("clip: "+Clipboard.ReadText());
            /*var bmp = Clipboard.ReadTexture(false);
            if (bmp != null)
            {
                var bytes = bmp.EncodeToPNG();
                File.WriteAllBytes("test.png", bytes);
            }*/

            //Clipboard.Write("собака!");
            if (Clipboard.WriteImage(outputTexture))
            {
                Debug.Log("Copied to clipboard");
            }
            else
            {
                Debug.Log("Clipboard failed");
            }
            
        }

        float sum = 0;
        for (int i=0; i<colorCount; i++)
        {
            sum += colors[i].percentage;

            Color temp;
            if (ColorUtility.TryParseHtmlString(colors[i].hex, out temp))
            {
                colors[i].color = temp;
            }
        }

        for (int i = 0; i < colorCount; i++)
        {
            colors[i].percentage /= sum;
        }
    }

19 View Source File : TimelineTrackGUI.cs
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski

float DrawInlineCurveButton(Rect rect, WindowState state)
        {
            if (!CanDrawInlineCurve())
            {
                //Force to close Inline Curve UI if the inline cannot be drawn.
                if (track.GetShowInlineCurves())
                    track.SetShowInlineCurves(false);
                return 0.0f;
            }

            // Override enable state to display "Show Inline Curves" button in disabled state.
            bool prevEnabledState = GUI.enabled;
            GUI.enabled = true;
            var showInlineCurves = track.GetShowInlineCurves();
            var tooltip = showInlineCurves ? Styles.trackCurvesBtnOnTooltip : Styles.trackCurvesBtnOffTooltip;
            var newValue = GUI.Toggle(rect, track.GetShowInlineCurves(), tooltip, DirectorStyles.Instance.trackCurvesButton);
            GUI.enabled = prevEnabledState;

            if (newValue != track.GetShowInlineCurves())
            {
                track.SetShowInlineCurves(newValue);
                state.GetWindow().treeView.CalculateRowRects();
            }

            return WindowConstants.trackHeaderButtonSize + WindowConstants.trackHeaderButtonPadding;
        }

19 View Source File : BlendShapesEditor.cs
License : MIT License
Project Creator : Interactml

void HeaderCallbackDelegate(Rect rect)
        {
            Rect R_1 = new Rect(rect.x + 14, rect.y, (rect.width - 10) / 2, EditorGUIUtility.singleLineHeight);
            EditorGUI.LabelField(R_1, "Name");

            Rect R_2 = new Rect(rect.x + 14 + ((rect.width - 30) / 2), rect.y, rect.width - ((rect.width - 10) / 2), EditorGUIUtility.singleLineHeight);
            EditorGUI.LabelField(R_2, "Skin Mesh Renderer");

            Rect R_3 = new Rect(rect.width + 5, rect.y + 1, 20, EditorGUIUtility.singleLineHeight - 2);
            MyBlendShapes.random = GUI.Toggle(R_3, MyBlendShapes.random, new GUIContent("R", "On Start Randomize the BlendShapes"), EditorStyles.miniButton);

        }

19 View Source File : VolumeComponentEditor.cs
License : MIT License
Project Creator : TheSlippyPenguin

protected void DrawOverrideCheckbox(SerializedDataParameter property)
        {
            var overrideRect = GUILayoutUtility.GetRect(17f, 17f, GUILayout.ExpandWidth(false));
            overrideRect.yMin += 4f;
            property.overrideState.boolValue = GUI.Toggle(overrideRect, property.overrideState.boolValue, CoreEditorUtils.GetContent("|Override this setting for this volume."), CoreEditorStyles.smallTickbox);
        }

19 View Source File : FileHistoryWindow.cs
License : MIT License
Project Creator : github-for-unity

private void ShowButton(Rect rect)
        {
            EditorGUI.BeginChangeCheck();
            
            locked = GUI.Toggle(rect, locked, GUIContent.none, Styles.LockButtonStyle);

            if (!EditorGUI.EndChangeCheck())
                return;

            this.OnSelectionChange();
        }

19 View Source File : Rigidbody2D_BodyType_Collision.cs
License : The Unlicense
Project Creator : Unity-Technologies

void OnGUI ()
	{
		var buttonRect = new Rect (20f, 360f, 310f, 30f);
        m_UseFullKinematicContacts = GUI.Toggle(buttonRect, m_UseFullKinematicContacts, "Use Full Kinematic Contacts is " + (m_UseFullKinematicContacts ? "ON" : "OFF"), "button");

		UpdatetFullKinematicContacts ();
    }

19 View Source File : InputAxisDrawer.cs
License : MIT License
Project Creator : Interactml

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            var indent = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;

            property.FindPropertyRelative("name").stringValue = label.text;


            // Calculate rects
            var activeRect = new Rect(position.x, position.y, 15, position.height);
            var LabelRect = new Rect(position.x + 15, position.y, EditorGUIUtility.labelWidth - 15, position.height);
            var valueRect = new Rect(EditorGUIUtility.labelWidth + 15, position.y, position.width - EditorGUIUtility.labelWidth - 20, position.height);
            var RawRect = new Rect(position.width - 3, position.y, 17, position.height);


            // Draw fields - preplaceds GUIContent.none to each so they are drawn without labels
            EditorGUI.PropertyField(activeRect, property.FindPropertyRelative("active"), GUIContent.none);
            EditorGUI.LabelField(LabelRect, label);

            EditorGUI.PropertyField(valueRect, property.FindPropertyRelative("input"), GUIContent.none);

            var RawProp = property.FindPropertyRelative("raw");

            RawProp.boolValue = GUI.Toggle(RawRect, RawProp.boolValue , new GUIContent("R","Use Raw Values for the Axis"),EditorStyles.miniButton);

            // Set indent back to what it was
            EditorGUI.indentLevel = indent;

            EditorGUI.EndProperty();
        }

19 View Source File : ConsoleWindow.cs
License : GNU General Public License v3.0
Project Creator : veesusmikelheir

private void DrawWindow(int id)
        {
            int bFontSize = GUI.skin.button.fontSize;
            int tfFontSize = GUI.skin.textField.fontSize;
            int tFontSize = GUI.skin.toggle.fontSize;
            int lFontSize = GUI.skin.label.fontSize;
            GUI.skin.button.fontSize = consoleFont.fontSize;
            GUI.skin.textField.fontSize = consoleFont.fontSize;
            GUI.skin.toggle.fontSize = consoleFont.fontSize;
            GUI.skin.label.fontSize = consoleFont.fontSize;

            if (cachedAC.Count == 0)
            {
                autoComplete = false;
            }

            // LISTENING TO THE KEY EVENTS
            if (Event.current.isKey && Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.Escape && autoComplete)
                {
                    forceClose = true;
                    autoComplete = false;

                    Event.current.Use();
                    return;
                }
                else if (Event.current.keyCode == KeyCode.Escape && !autoComplete)
                {
                    SetWindowOff();

                    Event.current.Use();
                    return;
                }

                // SUBMITS THE TEXTFIELD
                if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter)
                {
                    Console.ProcessInput(cmdText.TrimEnd(' '));
                    cmdText = string.Empty;
                    oldCmdText = null;

                    currHistory = -1;
                    completeIndex = 0;
                    autoComplete = false;

                    Event.current.Use();
                    return;
                }

                // AUTO COMPLETE TOGGLE
                if ((Event.current.modifiers == EventModifiers.Control || Event.current.modifiers == EventModifiers.Command) && Event.current.keyCode == KeyCode.Space)
                {
                    forceClose = false;

                    if (Regex.Matches(cmdText, "\"").Count % 2 == 0)
                        autoComplete = true;

                    justActivated = true;
                    oldCmdText = null;

                    Event.current.Use();
                    return;
                }

                // TAB AUTO COMPLETE
                if (Event.current.keyCode == KeyCode.Tab && Event.current.modifiers == EventModifiers.None && autoComplete)
                {
                    if (!selectComplete.Equals(string.Empty))
                    {
                        cmdText = selectComplete;
                        selectComplete = string.Empty;
                        moveCursor = true;

                        autoComplete = false;
                    }

                    Event.current.Use();
                    return;
                }

                // CYCLES HISTORY UP
                if (Event.current.keyCode == KeyCode.UpArrow && !autoComplete && Console.history.Count > 0)
                {
                    if (currHistory == -1)
                    {
                        cmdText = Console.history[Console.history.Count - 1];
                        currHistory = Console.history.Count - 1;
                    }
                    else
                    {
                        if (currHistory > 0)
                        {
                            cmdText = Console.history[currHistory - 1];
                            currHistory -= 1;
                        }
                    }

                    moveCursor = true;
                    Event.current.Use();
                    return;
                }
                else if (Event.current.keyCode == KeyCode.UpArrow && autoComplete)
                {
                    completeIndex--;

                    if (completeIndex < 0)
                        completeIndex = cachedAC.Count - 1;

                    aCompleteScroll.y = (25 * completeIndex) + 5;

                    Event.current.Use();
                    return;
                }

                // CYCLES HISTORY DOWN
                if (Event.current.keyCode == KeyCode.DownArrow && !autoComplete && Console.history.Count > 0)
                {
                    if (currHistory != -1)
                    {
                        if (currHistory < (Console.history.Count - 1))
                        {
                            cmdText = Console.history[currHistory + 1];
                            currHistory += 1;
                        }
                        else
                        {
                            cmdText = string.Empty;
                            currHistory = -1;
                        }
                    }

                    moveCursor = true;
                    Event.current.Use();
                    return;
                }
                else if (Event.current.keyCode == KeyCode.DownArrow && autoComplete)
                {
                    completeIndex++;

                    if (completeIndex > cachedAC.Count - 1)
                        completeIndex = 0;

                    aCompleteScroll.y = (25 * completeIndex) + 5;

                    Event.current.Use();
                    return;
                }

                // TRIGGER AUTO COMPLETE
                if (autoAC && Event.current.keyCode != KeyCode.None && Event.current.keyCode != KeyCode.Space && Event.current.keyCode != KeyCode.Escape && (!cmdText.Equals(oldCmdText) || cmdText.Equals(string.Empty)) && (Event.current.modifiers == EventModifiers.None || Event.current.modifiers == EventModifiers.Shift))
                {
                    if (cmdText.Equals(string.Empty))
                        forceClose = false;

                    autoComplete = !forceClose;
                }

                // FIXES SPACE && BACKSPACE
                if (autoAC && (Event.current.keyCode == KeyCode.Space) && Event.current.modifiers == EventModifiers.None)
                {
                    if (Regex.Matches(cmdText, "\"").Count % 2 == 0)
                        forceClose = false;

                    if (!forceClose)
                        autoComplete = true;
                }
            }

            // CONSOLE AREA
            GUI.BeginGroup(leftGroup);

            GUI.SetNextControlName(cmdName);
            cmdText = GUI.TextField(cmdRect, cmdText);

            if (cmdText.EndsWith(" ") && justActivated)
            {
                cmdText = cmdText.TrimEnd(' ');
                oldCmdText = null;
                justActivated = false;
            }

            if (!focus)
            {
                focus = true;
                GUI.FocusControl(cmdName);
            }

            textArea.wordWrap = false;
            textArea.clipping = TextClipping.Clip;
            textArea.richText = true;
            textArea.padding = new RectOffset(5, 5, 5, 5);
            textArea.font = consoleFont;

            tRect.width = TextSize.x;
            tRect.height = TextSize.y;

            GUI.BeginGroup(oRect, GUI.skin.textArea);
            consoleScroll = GUI.BeginScrollView(sRect, consoleScroll, tRect, false, true);
            GUI.Label(tRect, FullContent, textArea);
            GUI.EndScrollView();
            GUI.EndGroup();

            GUI.EndGroup();

            // MENU AREA
            GUI.BeginGroup(rightGroupA, GUI.skin.textArea);

            GUI.skin.button.fontStyle = FontStyle.Bold;

            if (GUI.Button(ulRect, openUnityLog))
                System.Diagnostics.Process.Start(Console.unityLogFile);

            if (GUI.Button(slRect, openSRMLLog))
                System.Diagnostics.Process.Start(Console.srmlLogFile);

            autoAC = GUI.Toggle(tacRect, autoAC, toggleAutoAC);

            if (autoAC != oldAutoAC)
            {
                if (autoAC)
                {
                    Console.LogSuccess("Auto complete will now open automatically.");
                }
                else
                {
                    Console.LogSuccess("Auto complete will only open by pressing CTRL+Space or CMD+Space");
                }

                oldAutoAC = autoAC;
            }

            GUI.EndGroup();

            GUI.BeginGroup(rightGroupB, GUI.skin.textArea);

            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUI.Label(cmRect, commands);
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;

            caRect.height = (30 * Console.cmdButtons.Count) + 5;
            commandScroll = GUI.BeginScrollView(csRect, commandScroll, caRect, false, true);
            GUI.BeginGroup(caRect);

            int y = 5;
            foreach (ConsoleButton button in Console.cmdButtons.Values)
            {
                btnRect.y = y;
                if (GUI.Button(btnRect, button.Text))
                    Console.ProcessInput(button.Command.TrimEnd(' '), true);

                y += 30;
            }

            GUI.EndGroup();
            GUI.EndScrollView();

            GUI.skin.button.fontStyle = FontStyle.Normal;

            GUI.EndGroup();

            // UPDATES THE SCROLL POSITION FOR THE CONSOLE TO SHOW LATEST MESSAGES
            if (updateDisplay)
            {
                fullText = string.Empty;
                for (int i = 0; i < Console.lines.Count; i++)
                {
                    fullText += $"{(i == 0 ? string.Empty : "\n")}{Console.lines[i]}";
                }

                consoleScroll.y = TextSize.y;
                updateDisplay = false;
            }

            // MOVES THE CURSOR AFTER AUTO COMPLETE
            if (moveCursor)
            {
                TextEditor txt = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                txt.MoveCursorToPosition(Vector2.one * 50000);

                autoComplete = false;
                moveCursor = false;
            }

            if (cmdText.Equals(string.Empty) && currHistory > -1)
                currHistory = -1;

            GUI.skin.button.fontSize = bFontSize;
            GUI.skin.textField.fontSize = tfFontSize;
            GUI.skin.toggle.fontSize = tFontSize;
            GUI.skin.label.fontSize = lFontSize;
        }

19 View Source File : TMP_EditorUtility.cs
License : MIT License
Project Creator : ashishgopalhattimare

public static bool EditorToggle(Rect position, bool value, GUIContent content, GUIStyle style)
        {
            var id = GUIUtility.GetControlID(content, FocusType.Keyboard, position);
            var evt = Event.current;

            // Toggle selected toggle on space or return key
            if (GUIUtility.keyboardControl == id && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter))
            {
                value = !value;
                evt.Use();
                GUI.changed = true;
            }

            if (evt.type == EventType.MouseDown && position.Contains(Event.current.mousePosition))
            {
                GUIUtility.keyboardControl = id;
                EditorGUIUtility.editingTextField = false;
                HandleUtility.Repaint();
            }
            
            return GUI.Toggle(position, id, value, content, style);
        }

19 View Source File : SF_PreviewWindow.cs
License : MIT License
Project Creator : XINCGer

public int OnGUI( int yOffset, int maxWidth ) {

			if( enabled == false )
				return yOffset;

			Rect topBar = new Rect( 0, yOffset, maxWidth, 18 );
			

			GUI.Box( topBar, "", EditorStyles.toolbar );

			Rect r = new Rect( topBar );
			r.width = maxWidth / 3;
			r.height = 16;
			r.x += 10;
			r.y += 1;

			//EditorGUILayout.BeginHorizontal();
			//{
			EditorGUI.BeginChangeCheck();
			mesh = (Mesh)EditorGUI.ObjectField(r, mesh, typeof( Mesh ), false );
			if( EditorGUI.EndChangeCheck() ) {
				targetFOV = 35f;
				//editor.Defocus(); // TODO: This is a bit hacky
			}

			r.x += r.width + 10;
			r.width *= 0.5f;
			EditorGUI.BeginChangeCheck();
			GUI.enabled = cam.clearFlags != CameraClearFlags.Skybox;
			//GUI.color = GUI.enabled ? Color.white : new Color(1f,1f,1f,0.5f);
			settings.colorBg = EditorGUI.ColorField( r, "", settings.colorBg );
			cam.backgroundColor = settings.colorBg;

			GUI.enabled = true;
			//GUI.color = Color.white;
			if( EditorGUI.EndChangeCheck() )
				UpdatePreviewBackgroundColor();


			r.x += r.width + 10;
			r.width += 10;


			GUI.enabled = RenderSettings.skybox != null;
			SkyboxOn = GUI.Toggle( r, SkyboxOn, "Skybox" );
			if(RenderSettings.skybox == null && SkyboxOn){
				SkyboxOn = false;
			}
			GUI.enabled = true;

			r.x += r.width + 10;
			settings.previewAutoRotate = GUI.Toggle( r, settings.previewAutoRotate, "Rotate" );


			Rect previewRect = new Rect( topBar );
			previewRect.y += topBar.height;
			previewRect.height = topBar.width;

			
			UpdateCameraZoom();
			DrawMeshGUI( previewRect );
			if(SF_Debug.renderDataNodes)
				GUI.Label(previewRect, "rotMesh.x = " + rotMesh.x + "  rotMesh.y = " + rotMesh.y);

			return (int)previewRect.yMax;
		}

19 View Source File : IKCtrlRightHand.cs
License : MIT License
Project Creator : m969

void OnGUI ()
		{
			Rect rect1 = new Rect (10, Screen.height - 20, 400, 30);
			isIkActive = GUI.Toggle (rect1, isIkActive, "IK Active");
		}

19 View Source File : RandomWind.cs
License : MIT License
Project Creator : m969

void OnGUI ()
		{
			Rect rect1 = new Rect (10, Screen.height - 40, 400, 30);
			isWindActive = GUI.Toggle (rect1, isWindActive, "Random Wind");
		}

19 View Source File : TimelineTrackGUI.cs
License : MIT License
Project Creator : BattleDawnNZ

float DrawInlineCurveButton(Rect rect, WindowState state)
        {
            if (!CanDrawInlineCurve())
            {
                return 0.0f;
            }

            // Override enable state to display "Show Inline Curves" button in disabled state.
            bool prevEnabledState = GUI.enabled;
            GUI.enabled = true;
            var newValue = GUI.Toggle(rect, track.GetShowInlineCurves(), GUIContent.none, DirectorStyles.Instance.curves);
            GUI.enabled = prevEnabledState;

            if (newValue != track.GetShowInlineCurves())
            {
                track.SetShowInlineCurves(newValue);
                state.GetWindow().treeView.CalculateRowRects();
            }

            return WindowConstants.trackHeaderButtonSize;
        }

19 View Source File : TimelineTrackBaseGUI.cs
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski

protected void DrawMuteButton(Rect rect, WindowState state)
        {
            using (new EditorGUI.DisabledScope(TimelineUtility.IsParentMuted(track)))
            {
                EditorGUI.BeginChangeCheck();
                var isMuted = track.mutedInHierarchy;
                var tooltip = isMuted ? Styles.trackMuteBtnOnTooltip : Styles.trackMuteBtnOffTooltip;
                var muted = GUI.Toggle(rect, isMuted, tooltip, TimelineWindow.styles.trackMuteButton);
                if (EditorGUI.EndChangeCheck())
                    MuteTrack.Mute(new[] { track }, muted);
            }
        }

19 View Source File : EditorUtilities.cs
License : MIT License
Project Creator : huailiang

internal static bool DrawHeader(string replacedle, SerializedProperty group, SerializedProperty activeField, PostProcessEffectSettings target, Action resetAction, Action removeAction)
        {
            replacedert.IsNotNull(group);
            replacedert.IsNotNull(activeField);
            replacedert.IsNotNull(target);

            var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

            var labelRect = backgroundRect;
            labelRect.xMin += 32f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;

            var toggleRect = backgroundRect;
            toggleRect.x += 16f;
            toggleRect.y += 2f;
            toggleRect.width = 13f;
            toggleRect.height = 13f;

            var menuIcon = Styling.paneOptionsIcon;
            var menuRect = new Rect(labelRect.xMax + 4f, labelRect.y + 4f, menuIcon.width, menuIcon.height);

            // Background rect should be full-width
            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            // Background
            EditorGUI.DrawRect(backgroundRect, Styling.headerBackground);

            // replacedle
            using (new EditorGUI.DisabledScope(!activeField.boolValue))
                EditorGUI.LabelField(labelRect, GetContent(replacedle), EditorStyles.boldLabel);

            // foldout
            group.serializedObject.Update();
            group.isExpanded = GUI.Toggle(foldoutRect, group.isExpanded, GUIContent.none, EditorStyles.foldout);
            group.serializedObject.ApplyModifiedProperties();

            // Active checkbox
            activeField.serializedObject.Update();
            activeField.boolValue = GUI.Toggle(toggleRect, activeField.boolValue, GUIContent.none, Styling.smallTickbox);
            activeField.serializedObject.ApplyModifiedProperties();

            // Dropdown menu icon
            GUI.DrawTexture(menuRect, menuIcon);

            // Handle events
            var e = Event.current;

            if (e.type == EventType.MouseDown)
            {
                if (menuRect.Contains(e.mousePosition))
                {
                    ShowHeaderContextMenu(new Vector2(menuRect.x, menuRect.yMax), target, resetAction, removeAction);
                    e.Use();
                }
                else if (labelRect.Contains(e.mousePosition))
                {
                    if (e.button == 0)
                        group.isExpanded = !group.isExpanded;
                    else
                        ShowHeaderContextMenu(e.mousePosition, target, resetAction, removeAction);

                    e.Use();
                }
            }

            return group.isExpanded;
        }

19 View Source File : DeveloperConsole.cs
License : MIT License
Project Creator : mustafayaya

void ConsoleWindow(int windowID)
        {

            printLogs = GUI.Toggle(new Rect(10, 5, 10, 10), printLogs, "", skin.GetStyle("logButton"));
            printWarnings = GUI.Toggle(new Rect(25, 5, 10, 10), printWarnings, "", skin.GetStyle("warningButton"));
            printErrors = GUI.Toggle(new Rect(40, 5, 10, 10), printErrors, "", skin.GetStyle("errorButton"));
            printNetwork = GUI.Toggle(new Rect(55, 5, 10, 10), printNetwork, "", skin.GetStyle("networkButton"));

            if (GUI.Button(new Rect(windowRect.width - 25, 7, 15, 5), "-", skin.GetStyle("exitButton")))
            {
                _active = !_active;
            }

            if (Event.current.keyCode == KeyCode.UpArrow && Event.current.type == EventType.KeyDown)
            {
                if (GUI.GetNameOfFocusedControl() == "consoleInputField")
                {
                    InputHistoryHandler();
                    FocusOnInputField(false);
                }
            }
#if UNITY_STANDALONE
            GUI.SetNextControlName("dragHandle");

            GUI.DragWindow(new Rect(0, 0, windowRect.width, 20));//Draw drag handle of window
#endif
            int scrollHeight = 0;
            GUI.SetNextControlName("outputBox");

            GUI.Box(new Rect(20, 20, windowRect.width - 40, windowRect.height - 85), "", skin.box);//Draw console window box

            GUI.SetNextControlName("consoleInputField");
            Rect inputFieldRect = new Rect(20, windowRect.height - 45, windowRect.width - 160, 25);
            Widgets.Instance.DrawCommandHints(inputFieldRect, skin.GetStyle("hint"));
            input = GUI.TextField(inputFieldRect, input, inputLimit, skin.textField);


            foreach (ConsoleOutput c in consoleOutputs)
            {
                scrollHeight += c.lines * lineSpacing;
            }

            scrollPosition = GUI.BeginScrollView(new Rect(20, 20, windowRect.width - 40, windowRect.height - 85), scrollPosition, new Rect(20, 20, windowRect.width - 60, scrollHeight));
            if (scrollDownTrigger)
            {
                scrollPosition = new Vector2(scrollPosition.x, scrollHeight);
                scrollDownTrigger = false;
            }

            GUI.SetNextControlName("textArea");
            DrawOutput();

            GUI.EndScrollView();

            GUI.SetNextControlName("submitButton");

            if (GUI.Button(new Rect(windowRect.width - 130, windowRect.height - 45, 80, 25), "Submit", skin.button))
            {
                if (!String.IsNullOrEmpty(input))
                {
                    SubmitInput(input);
                    scrollPosition = new Vector2(scrollPosition.x, consoleOutputs.Count * 40);
                }

            }

            if (inputFocusTrigger)
            {
                FocusOnInputField(false);

            }
            if (!String.IsNullOrEmpty(input) && Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp)
            {

                if (GUI.GetNameOfFocusedControl() == "consoleInputField" || GUI.GetNameOfFocusedControl() == "")
                {
                    if (inputFocusTrigger)
                    {
                        inputFocusTrigger = false;
                    }
                    else
                    {
                        SubmitInput(input);

                    }

                }

            }
            GUI.SetNextControlName("clearButton");

            if (GUI.Button(new Rect(windowRect.width - 40, windowRect.height - 45, 20, 25), "X", skin.button))
            {
                consoleOutputs.Clear();
                inputHistory.Clear();
                scrollPosition = new Vector2(scrollPosition.x, consoleOutputs.Count * 20);
            }

            if (String.IsNullOrEmpty(input) && Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp)
            {

                GUI.FocusControl("consoleInputField");

            }
            if (GUI.GetNameOfFocusedControl() == "" && submitFocusTrigger)
            {
                GUI.FocusControl("consoleInputField");
                submitFocusTrigger = false;
            }

            GUI.Box(new Rect(windowRect.width - 15, windowRect.height - 15, 10, 10), "", skin.GetStyle("corner"));

            WindowResizeHandler();
        }

19 View Source File : TimelineTrackGUI.cs
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski

void DrawLockMarkersButton(Rect rect, WindowState state)
        {
            var hasMarkers = track.GetMarkerCount() != 0;
            var markersShown = showMarkers && hasMarkers;
            var style = TimelineWindow.styles.trackMarkerButton;

            EditorGUI.BeginChangeCheck();
            var tooltip = markersShown ? Styles.trackMarkerBtnOnTooltip : Styles.trackMarkerBtnOffTooltip;
            var toggleMarkers = GUI.Toggle(rect, markersShown, tooltip, style);
            if (EditorGUI.EndChangeCheck() && hasMarkers)
                track.SetShowTrackMarkers(toggleMarkers);
        }

19 View Source File : ActiveMeshesEditor.cs
License : MIT License
Project Creator : Interactml

void HeaderCallbackDelegate(Rect rect)
        {
            Rect R_0 = new Rect(rect.x, rect.y, 15, EditorGUIUtility.singleLineHeight);
            Rect R_01 = new Rect(rect.x + 14, rect.y, 35, EditorGUIUtility.singleLineHeight);
            Rect R_1 = new Rect(rect.x + 14 + 25, rect.y, (rect.width - 10) / 2, EditorGUIUtility.singleLineHeight);
            Rect R_2 = new Rect(rect.x  + 35 + ((rect.width - 30) / 2), rect.y, rect.width - ((rect.width) / 2) - 25, EditorGUIUtility.singleLineHeight);

            MyMeshes.showMeshesList  = EditorGUI.ToggleLeft(R_0,"", MyMeshes.showMeshesList);
            EditorGUI.LabelField(R_01, new GUIContent(" #", "Index"), EditorStyles.miniLabel);
            EditorGUI.LabelField(R_1, "Active Meshes", EditorStyles.miniLabel);
            EditorGUI.LabelField(R_2, "CURRENT", EditorStyles.centeredGreyMiniLabel);

            Rect R_3 = new Rect(rect.width + 5, rect.y + 1, 20, EditorGUIUtility.singleLineHeight - 2);
            MyMeshes.random = GUI.Toggle(R_3, MyMeshes.random, new GUIContent("R", "On Start replacedigns a Random Mesh"), EditorStyles.miniButton);
        }

19 View Source File : Menu.cs
License : MIT License
Project Creator : ThePotato97

private static void anywhereActions()
        {
            if (GUI.Toggle(new Rect(1120f, 325f, 200f, 20f), showItemList, "Show Item Spawner") != showItemList)
            {
                showItemList = !showItemList;
            }
        }

19 View Source File : TimelineTrackGUI.cs
License : GNU Lesser General Public License v3.0
Project Creator : disruptorbeam

float DrawInlineCurveButton(Rect rect, WindowState state)
        {
            if (!CanDrawInlineCurve())
            {
                //Force to close Inline Curve UI if the inline cannot be drawn.
                if (track.GetShowInlineCurves())
                    track.SetShowInlineCurves(false);
                return 0.0f;
            }

            // Override enable state to display "Show Inline Curves" button in disabled state.
            bool prevEnabledState = GUI.enabled;
            GUI.enabled = true;
            var newValue = GUI.Toggle(rect, track.GetShowInlineCurves(), GUIContent.none, DirectorStyles.Instance.curves);
            GUI.enabled = prevEnabledState;

            if (newValue != track.GetShowInlineCurves())
            {
                track.SetShowInlineCurves(newValue);
                state.GetWindow().treeView.CalculateRowRects();
            }

            return WindowConstants.trackHeaderButtonSize;
        }

19 View Source File : Menu.cs
License : MIT License
Project Creator : ThePotato97

private static void hudToggles()
        {
            GUI.Label(new Rect(920f, 295f, 200f, 20f), "ESP:");
            if (GUI.Toggle(new Rect(920f, 320f, 200f, 20f), GhostESP, "Ghost") != GhostESP)
            {
                GhostESP = !GhostESP;
            }
            if (GUI.Toggle(new Rect(920f, 370f, 200f, 20f), PlayerESP, "Player") != PlayerESP)
            {
                PlayerESP = !PlayerESP;
            }
            if (GUI.Toggle(new Rect(920f, 395f, 200f, 20f), OuijaESP, "Ouija Board") != OuijaESP)
            {
                OuijaESP = !OuijaESP;
            }
            if (GUI.Toggle(new Rect(920f, 420f, 200f, 20f), KeyESP, "Key") != KeyESP)
            {
                KeyESP = !KeyESP;
            }
            if (GUI.Toggle(new Rect(920f, 445f, 200f, 20f), EvidenceESP, "Evidence") != EvidenceESP)
            {
                EvidenceESP = !EvidenceESP;
            }

            if (GUI.Toggle(new Rect(1120f, 400f, 200f, 20f), SpeedHack, "Speedhack") != SpeedHack)
            {
                SpeedHack = !SpeedHack;
            }

            if (GUI.Toggle(new Rect(1120, 415f, 200f, 20f), fullbrighttoggle, "FullBright") != fullbrighttoggle)
            {
                fullbrighttoggle = !fullbrighttoggle;
                FullBright.changeBright();
            }
            
            GUI.Label(new Rect(740f, 145f, 200f, 20f), "Lights:");
            if (GUI.Button(new Rect(740f, 175f, 200f, 20f), "All Lights On"))
            {
                foreach (LightSwitch lightSwitch1 in Main.lightSwitches)
                {
                    lightSwitch1.TurnOn(true);
                    lightSwitch1.TurnOnNetworked(true);
                }
            }
            if (GUI.Button(new Rect(740f, 195f, 200f, 20f), "All Lights Off"))
            {
                foreach (LightSwitch lightSwitch2 in Main.lightSwitches)
                {
                    lightSwitch2.TurnOff();
                    lightSwitch2.TurnOffNetworked(true);
                }
            }

            if (GUI.Toggle(new Rect(1120f, 300f, 200f, 20f), ShowInfoGhost, "Show Ghost Info") != ShowInfoGhost)
            {
                ShowInfoGhost = !ShowInfoGhost;
            }
            if (GUI.Toggle(new Rect(1120f, 250f, 200f, 20f), ShowInfoPlayer, "Show Player Info") != ShowInfoPlayer)
            {
                ShowInfoPlayer = !ShowInfoPlayer;
            }
            if (GUI.Toggle(new Rect(1120f, 200f, 200f, 20f), showMissionInfo, "Show Player Info") != showMissionInfo)
            {
                showMissionInfo = !showMissionInfo;
            }
        }

19 View Source File : MalbersEditor.cs
License : MIT License
Project Creator : Interactml

public static bool DrawHeaderFoldout(string replacedle, bool state)
        {
            var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

            var labelRect = backgroundRect;
            labelRect.xMin += 16f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;

            // Background rect should be full-width
            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            // Background
            float backgroundTint = EditorGUIUtility.isProSkin ? 0.1f : 1f;
            EditorGUI.DrawRect(backgroundRect, new Color(backgroundTint, backgroundTint, backgroundTint, 0.2f));

            // replacedle
            EditorGUI.LabelField(labelRect, replacedle, EditorStyles.boldLabel);

            // Active checkbox
            state = GUI.Toggle(foldoutRect, state, GUIContent.none, EditorStyles.foldout);

            var e = Event.current;
            if (e.type == EventType.MouseDown && backgroundRect.Contains(e.mousePosition) && e.button == 0)
            {
                state = !state;
                e.Use();
            }

            return state;
        }

19 View Source File : CoreEditorUtils.cs
License : MIT License
Project Creator : TheSlippyPenguin

public static bool DrawHeaderFoldout(GUIContent replacedle, bool state, bool isBoxed = false, Func<bool> isAdvanced = null, Action switchAdvanced = null)
        {
            const float height = 17f;
            var backgroundRect = GUILayoutUtility.GetRect(1f, height);

            var labelRect = backgroundRect;
            labelRect.xMin += 16f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;
            
            var advancedRect = new Rect();
            if (isAdvanced != null)
            {
                advancedRect = backgroundRect;
                advancedRect.x += advancedRect.width - 16 - 1;
                advancedRect.y -= 2;
                advancedRect.height = 16;
                advancedRect.width = 16;

                GUIStyle styleAdvanced = new GUIStyle(GUI.skin.toggle);
                styleAdvanced.normal.background = isAdvanced()
                    ? Resources.Load<Texture2D>("Advanced_Pressed_mini")
                    : Resources.Load<Texture2D>("Advanced_UnPressed_mini");
                styleAdvanced.onActive.background = styleAdvanced.normal.background;
                styleAdvanced.onFocused.background = styleAdvanced.normal.background;
                styleAdvanced.onNormal.background = styleAdvanced.normal.background;
                styleAdvanced.onHover.background = styleAdvanced.normal.background;
                styleAdvanced.active.background = styleAdvanced.normal.background;
                styleAdvanced.focused.background = styleAdvanced.normal.background;
                styleAdvanced.hover.background = styleAdvanced.normal.background;
                EditorGUI.BeginChangeCheck();
                GUI.Toggle(advancedRect, isAdvanced(), GUIContent.none, styleAdvanced);
                if(EditorGUI.EndChangeCheck() && switchAdvanced != null)
                {
                    switchAdvanced();
                }
            }

            // Background rect should be full-width
            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            if (isBoxed)
            {
                labelRect.xMin += 5;
                foldoutRect.xMin += 5;
                backgroundRect.xMin = EditorGUIUtility.singleLineHeight;
                backgroundRect.width -= 3;
            }

            // Background
            float backgroundTint = EditorGUIUtility.isProSkin ? 0.1f : 1f;
            EditorGUI.DrawRect(backgroundRect, new Color(backgroundTint, backgroundTint, backgroundTint, 0.2f));

            // replacedle
            EditorGUI.LabelField(labelRect, replacedle, EditorStyles.boldLabel);

            // Active checkbox
            state = GUI.Toggle(foldoutRect, state, GUIContent.none, EditorStyles.foldout);

            var e = Event.current;
            if (e.type == EventType.MouseDown && backgroundRect.Contains(e.mousePosition) && !advancedRect.Contains(e.mousePosition) && e.button == 0)
            {
                state = !state;
                e.Use();
            }
            
            return state;
        }

19 View Source File : GUI.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static void Toggle(SmartRect position, Setting<bool> val, string label, float offset, bool move = false)
        {
            UGUI.Label(position.ToRect(), label, Style.Label);
            position.MoveOffsetX(position.width - Style.Height);
            val.Value = UGUI.Toggle(position.ToRect(), val.Value, string.Empty, Style.Toggle);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }
        }

19 View Source File : CoreEditorUtils.cs
License : MIT License
Project Creator : TheSlippyPenguin

public static bool DrawHeaderToggle(GUIContent replacedle, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null)
        {
            var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

            var labelRect = backgroundRect;
            labelRect.xMin += 32f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;

            var toggleRect = backgroundRect;
            toggleRect.x += 16f;
            toggleRect.y += 2f;
            toggleRect.width = 13f;
            toggleRect.height = 13f;

            // Background rect should be full-width
            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            // Background
            float backgroundTint = EditorGUIUtility.isProSkin ? 0.1f : 1f;
            EditorGUI.DrawRect(backgroundRect, new Color(backgroundTint, backgroundTint, backgroundTint, 0.2f));

            // replacedle
            using (new EditorGUI.DisabledScope(!activeField.boolValue))
                EditorGUI.LabelField(labelRect, replacedle, EditorStyles.boldLabel);

            // Foldout
            group.serializedObject.Update();
            group.isExpanded = GUI.Toggle(foldoutRect, group.isExpanded, GUIContent.none, EditorStyles.foldout);
            group.serializedObject.ApplyModifiedProperties();

            // Active checkbox
            activeField.serializedObject.Update();
            activeField.boolValue = GUI.Toggle(toggleRect, activeField.boolValue, GUIContent.none, CoreEditorStyles.smallTickbox);
            activeField.serializedObject.ApplyModifiedProperties();

            // Context menu
            var menuIcon = CoreEditorStyles.paneOptionsIcon;
            var menuRect = new Rect(labelRect.xMax + 4f, labelRect.y + 4f, menuIcon.width, menuIcon.height);

            if (contextAction != null)
                GUI.DrawTexture(menuRect, menuIcon);

            // Handle events
            var e = Event.current;

            if (e.type == EventType.MouseDown)
            {
                if (contextAction != null && menuRect.Contains(e.mousePosition))
                {
                    contextAction(new Vector2(menuRect.x, menuRect.yMax));
                    e.Use();
                }
                else if (labelRect.Contains(e.mousePosition))
                {
                    if (e.button == 0)
                        group.isExpanded = !group.isExpanded;
                    else if (contextAction != null)
                        contextAction(e.mousePosition);

                    e.Use();
                }
            }

            return group.isExpanded;
        }

19 View Source File : InputRowDrawer.cs
License : MIT License
Project Creator : Interactml

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // EditorGUI.HelpBox(position, "",MessageType.None);

            EditorGUI.BeginProperty(position, label, property);

            var DefaultPosition = position;

            var indent = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;

            property.FindPropertyRelative("name").stringValue = label.text;

            var height = EditorGUIUtility.singleLineHeight;
            // Calculate rects
            var activeRect = new Rect(position.x, position.y, 15, height);
            var LabelRect = new Rect(position.x + 17, position.y, 100, height);


            // Draw fields - preplaceds GUIContent.none to each so they are drawn without labels
            EditorGUI.PropertyField(activeRect, property.FindPropertyRelative("active"), GUIContent.none);
            EditorGUI.LabelField(LabelRect, label, EditorStyles.miniBoldLabel);

            //Set Rect to the Parameters Values
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Preplacedive), new GUIContent(" "));

            // Calculate rects
            var typeRect = new Rect(position.x - 30, position.y, 44, height);
            var valueRect = new Rect(position.x - 30 + 45, position.y, position.width / 2 - 11, height);
            var ActionRect = new Rect(position.width / 2 + position.x - 30 + 40 - 5, position.y, (position.width / 2 - 7) - 16 , height);
            var ShowRect = new Rect(DefaultPosition.width+6 , position.y, 16, height-1);

            EditorGUI.PropertyField(typeRect, property.FindPropertyRelative("type"), GUIContent.none);

            InputType current = (InputType)property.FindPropertyRelative("type").enumValueIndex;
            switch (current)
            {
                case InputType.Input:
                    EditorGUI.PropertyField(valueRect, property.FindPropertyRelative("input"), GUIContent.none);
                    break;
                case InputType.Key:
                    EditorGUI.PropertyField(valueRect, property.FindPropertyRelative("key"), GUIContent.none);
                    break;
                default:
                    break;
            }

              EditorGUI.PropertyField(ActionRect, property.FindPropertyRelative("GetPressed"), GUIContent.none);

            SerializedProperty show = property.FindPropertyRelative("ShowEvents");


            show.boolValue = GUI.Toggle(ShowRect, show.boolValue, new GUIContent("" /*!show.boolValue ? "▼" : "▲"*/, "Show Events for the " +property.FindPropertyRelative("name").stringValue +" Input"), EditorStyles.foldout);

            //if (show.boolValue)
            //{
            //    DefaultPosition.y += EditorGUIUtility.singleLineHeight+3;



            //    InputButton enumValueIndex = (InputButton)property.FindPropertyRelative("GetPressed").enumValueIndex;

              

            //    switch (enumValueIndex)
            //    {
            //        case InputButton.Press:
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputPressed"));

            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputChanged"));

            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputUp"));

            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputDown"));
            //            break;
            //        case InputButton.Down:
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputDown"));

            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputChanged"));
            //            break;
            //        case InputButton.Up:
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputUp"));

            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputChanged"));
            //            break;
            //        case InputButton.LongPress:
            //            Rect LonRect = DefaultPosition;
            //            LonRect.height = EditorGUIUtility.singleLineHeight;
            //            EditorGUI.PropertyField(LonRect, property.FindPropertyRelative("LongPressTime"), new GUIContent("On Long Press", "Time the Input Should be Pressed"));
            //            DefaultPosition.y += EditorGUIUtility.singleLineHeight + 3;
                      
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnLongPress"), new GUIContent("On Long Press"));
            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnPressedNormalized"), new GUIContent("On Pressed Time Normalized"));
            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputDown"), new GUIContent("On Pressed Down"));
            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputUp"), new GUIContent("On Pressed Interrupted"));
            //            DefaultPosition.y += EventHeight;
            //            break;
            //        case InputButton.DoubleTap:
            //            Rect LonRect1 = DefaultPosition;
            //            LonRect1.height = EditorGUIUtility.singleLineHeight;
            //            EditorGUI.PropertyField(LonRect1, property.FindPropertyRelative("DoubleTapTime"), new GUIContent("Double Tap Time", "Time between the double tap"));
            //            DefaultPosition.y += EditorGUIUtility.singleLineHeight + 3;

            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnInputDown"), new GUIContent("On First Tap"));
            //            DefaultPosition.y += EventHeight;
            //            EditorGUI.PropertyField(DefaultPosition, property.FindPropertyRelative("OnDoubleTap"));
            //            break;
            //        default:
            //            break;
            //    }
            //}

            // Set indent back to what it was
            EditorGUI.indentLevel = indent;

            EditorGUI.EndProperty();
        }

19 View Source File : Rigidbody2D_Simulated.cs
License : The Unlicense
Project Creator : Unity-Technologies

void OnGUI ()
	{
		// Finish if no body.
		if (m_Body == null)
			return;

		var simulated = m_Body.simulated;

		// Show simulated toggle.
		var buttonRect = new Rect (20f, 50f, 310f, 30f);
        simulated = GUI.Toggle(buttonRect, simulated, "Rigidbody2D.simulated is " + (simulated ? "ON" : "OFF"), "button");

		// Set the simulated state if it has changed.
		if (m_Body.simulated != simulated)
			m_Body.simulated = simulated;
    }

19 View Source File : TreeControl.cs
License : MIT License
Project Creator : github-for-unity

public TreeNodeRenderResult Render(Rect rect, float indentation, bool isSelected, bool treeIsBusy, GUIStyle toggleStyle, GUIStyle nodeStyle, GUIStyle activeNodeStyle)
        {
            var renderResult = TreeNodeRenderResult.None;

            if (treeIsBusy)
            {
                GUI.enabled = false;
            }

            if (IsHidden)
                return renderResult;

            var fillRect = rect;
            var nodeStartX = Level * indentation + rect.x;
            nodeStartX += 2 * level;

            var nodeRect = new Rect(nodeStartX, rect.y, fillRect.width - nodeStartX, rect.height);

            var reserveToggleSpace = TreeIsCheckable || isFolder;
            var toggleRect = new Rect(nodeStartX, nodeRect.y, reserveToggleSpace ? indentation : 0, nodeRect.height);

            nodeStartX += toggleRect.width;
            if (reserveToggleSpace)
            {
                nodeStartX += 2;
            }

            var checkRect = new Rect(nodeStartX, nodeRect.y, TreeIsCheckable ? indentation : 0, nodeRect.height);

            nodeStartX += checkRect.width;
            if (TreeIsCheckable)
            {
                nodeStartX += 2;
            }

            var iconRect = new Rect(nodeStartX, nodeRect.y, fillRect.width - nodeStartX, nodeRect.height);
            var statusRect = new Rect(iconRect.x + 6, iconRect.yMax - 9, 9, 9);

            var contentStyle = IsActive ? activeNodeStyle : nodeStyle;

            if (Event.current.type == EventType.Repaint)
            {
                contentStyle.Draw(fillRect, GUIContent.none, false, false, false, isSelected);
            }

            var styleOn = false;
            if (IsFolderOrContainer)
            {
                styleOn = !IsCollapsed;

                if (Event.current.type == EventType.Repaint)
                {
                    toggleStyle.Draw(toggleRect, GUIContent.none, false, false, styleOn, isSelected);
                }

                EditorGUI.BeginChangeCheck();
                {
                    GUI.Toggle(toggleRect, !IsCollapsed, GUIContent.none, GUIStyle.none);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    renderResult = TreeNodeRenderResult.VisibilityChange;
                }
            }

            if (TreeIsCheckable)
            {
                var selectionStyle = GUI.skin.toggle;
                var selectionValue = false;

                if (CheckState == CheckState.Checked)
                {
                    selectionValue = true;
                }
                else if (CheckState == CheckState.Mixed)
                {
                    selectionStyle = Styles.ToggleMixedStyle;
                }

                EditorGUI.BeginChangeCheck();
                {
                    GUI.Toggle(checkRect, selectionValue, GUIContent.none, selectionStyle);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    renderResult = TreeNodeRenderResult.CheckChange;
                }
            }

            if (Event.current.type == EventType.Repaint)
            {
                contentStyle.Draw(iconRect, content, false, false, false, isSelected);
            }

            if (IconBadge != null)
            {
                GUI.DrawTexture(statusRect, IconBadge);
            }

            if (treeIsBusy)
            {
                GUI.enabled = true;
            }

            return renderResult;
        }

19 View Source File : RuntimeUrdfImporterExample.cs
License : Apache License 2.0
Project Creator : Unity-Technologies

void OnGUI()
    {
        urdfFilepath = GUI.TextField(new Rect(10, 50, 500, 25), urdfFilepath);
        setImmovableLink = GUI.Toggle(new Rect(10, 75, 200, 25), setImmovableLink, "set immovable link");
        if (setImmovableLink)
        {
            immovableLinkName = GUI.TextField(new Rect(220, 75, 200, 25), immovableLinkName);
        }

        useVHACD = GUI.Toggle(new Rect(10, 100, 200, 25), useVHACD, "Use vHACD");
        showProgress = GUI.Toggle(new Rect(10, 125, 200, 25), showProgress, "Show Progress (experimental)");
        if (!isLoading && GUI.Button(new Rect(530, 50, 150, 25), "Load UDRF File"))
        {
            StartCoroutine(LoadUrdf());
        }
    }

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

bool SpecialToggle(bool value, string name, out bool rightClicked)
        {
            var rect = GUILayoutUtility.GetRect(EditorGUIHelper.GetContent(name), EditorStyles.toolbarButton);

            var e = Event.current;
            rightClicked = (e.type == EventType.MouseUp && rect.Contains(e.mousePosition) && e.button == 1);

            return GUI.Toggle(rect, value, name, EditorStyles.toolbarButton);
        }

19 View Source File : StyleDrawer.cs
License : MIT License
Project Creator : WooshiiDev

private void DrawFoldout(Rect rect, bool foldout)
        {
            GUI.Toggle (GetToggleRect (rect), foldout, GUIContent.none, EditorStyles.foldout);
        }

19 View Source File : GUI.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static void Toggle(Rect position, Setting<bool> val, string label)
        {
            UGUI.Label(position, label, Style.Label);
            val.Value = UGUI.Toggle(new Rect(position.x + position.width - Style.Height, position.y, Style.Height, Style.Height), val.Value, string.Empty, Style.Toggle);
        }

19 View Source File : GridGeneratorEditor.cs
License : MIT License
Project Creator : XINCGer

void DrawWidthDepthFields (GridGraph graph, out int newWidth, out int newDepth) {
			lockStyle = lockStyle ?? AstarPathEditor.astarSkin.FindStyle("GridSizeLock") ?? new GUIStyle();

			GUILayout.BeginHorizontal();
			GUILayout.BeginVertical();
			newWidth = EditorGUILayout.IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width);
			newDepth = EditorGUILayout.IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth);

			// Clamping will be done elsewhere as well
			// but this prevents negative widths from being converted to positive ones (since an absolute value will be taken)
			newWidth = Mathf.Max(newWidth, 1);
			newDepth = Mathf.Max(newDepth, 1);

			GUILayout.EndVertical();

			Rect lockRect = GUILayoutUtility.GetRect(lockStyle.fixedWidth, lockStyle.fixedHeight);

			GUILayout.EndHorizontal();

			// All the layouts mess up the margin to the next control, so add it manually
			GUILayout.Space(2);

			// Add a small offset to make it better centred around the controls
			lockRect.y += 3;
			lockRect.width = lockStyle.fixedWidth;
			lockRect.height = lockStyle.fixedHeight;
			lockRect.x += lockStyle.margin.left;
			lockRect.y += lockStyle.margin.top;

			locked = GUI.Toggle(lockRect, locked,
				new GUIContent("", "If the width and depth values are locked, " +
					"changing the node size will scale the grid while keeping the number of nodes consistent " +
					"instead of keeping the size the same and changing the number of nodes in the graph"), lockStyle);
		}

19 View Source File : GUIControlsFREE.cs
License : MIT License
Project Creator : m969

private void OnGUI()
        {
			//If not dead.
			if(!rpgCharacterController.isDead)
			{
				//Actions.
				if(rpgCharacterController.canAction)
				{
					//Character is on the ground.
					if(rpgCharacterMovementController.MaintainingGround())
					{
						if(!navAgentToggle)
						{
							//Blocking.
							blockGui = GUI.Toggle(new Rect(25, 215, 100, 30), blockGui, "Block");
							if(blockGui)
							{
								if(!blockToggle)
								{
									blockToggle = true;
									rpgCharacterController.canBlock = false;
									rpgCharacterController.isBlocking = true;
									rpgCharacterController.animator.SetBool("Blocking", true);
									rpgCharacterMovementController.canMove = false;
									rpgCharacterController.animator.SetTrigger("BlockTrigger");
								}
							}
							if(!blockGui)
							{
								if(blockToggle)
								{
									rpgCharacterController.isBlocking = false;
									rpgCharacterController.animator.SetBool("Blocking", false);
									rpgCharacterMovementController.canMove = true;
									blockToggle = false;
									rpgCharacterController.canBlock = true;
								}
							}
							//Blocking.
							if(blockGui)
							{
								if(GUI.Button(new Rect(30, 240, 100, 30), "Get Hit"))
								{
									rpgCharacterController.GetHit();
								}
								if(GUI.Button(new Rect(30, 270, 100, 30), "Block Break"))
								{
									StartCoroutine(rpgCharacterController._BlockBreak());
								}
							}
							//Not Blocking.
							else if(!rpgCharacterController.isBlocking)
							{
								//Rolling.
								if(GUI.Button(new Rect(25, 15, 100, 30), "Roll Forward"))
								{
									StartCoroutine(rpgCharacterMovementController._Roll(1));
								}
								if(GUI.Button(new Rect(130, 15, 100, 30), "Roll Backward"))
								{
									StartCoroutine(rpgCharacterMovementController._Roll(3));
								}
								if(GUI.Button(new Rect(25, 45, 100, 30), "Roll Left"))
								{
									StartCoroutine(rpgCharacterMovementController._Roll(4));
								}
								if(GUI.Button(new Rect(130, 45, 100, 30), "Roll Right"))
								{
									StartCoroutine(rpgCharacterMovementController._Roll(2));
								}
								//Dodging.
								if(GUI.Button(new Rect(235, 15, 100, 30), "Dodge Left"))
								{
									StartCoroutine(rpgCharacterController._Dodge(1));
								}
								if(GUI.Button(new Rect(235, 45, 100, 30), "Dodge Right"))
								{
									StartCoroutine(rpgCharacterController._Dodge(2));
								}
								//ATTACK LEFT.
								if(rpgCharacterWeaponController.leftWeapon != 0 && rpgCharacterWeaponController.leftWeapon != 7)
								{
									if(GUI.Button(new Rect(25, 85, 100, 30), "Attack L"))
									{
										rpgCharacterController.Attack(1);
									}
								}
								//ATTACK RIGHT.
								if(rpgCharacterController.animator.GetInteger("RightWeapon") != 0)
								{
									if(GUI.Button(new Rect(130, 85, 100, 30), "Attack R"))
									{
										rpgCharacterController.Attack(2);
									}
								}
								//Kicking.
								if(GUI.Button(new Rect(25, 115, 100, 30), "Left Kick"))
								{
									rpgCharacterController.AttackKick(1);
								}
								if(GUI.Button(new Rect(130, 115, 100, 30), "Right Kick"))
								{
									rpgCharacterController.AttackKick(2);
								}
								if(GUI.Button(new Rect(30, 240, 100, 30), "Get Hit"))
								{
									rpgCharacterController.GetHit();
								}
								//Weapon Switching.
								if(!rpgCharacterMovementController.isMoving)
								{
									if(rpgCharacterController.weapon != Weapon.UNARMED)
									{
										if(GUI.Button(new Rect(1115, 310, 100, 30), "Unarmed"))
										{
											StartCoroutine(rpgCharacterWeaponController._SwitchWeapon(0));
											rpgCharacterController.canAction = true;
										}
									}
									if(rpgCharacterController.weapon != Weapon.TWOHANDSWORD)
									{
										if(GUI.Button(new Rect(1115, 340, 100, 30), "2 Hand Sword"))
										{
											StartCoroutine(rpgCharacterWeaponController._SwitchWeapon(1));
										}
									}
								}
							}
						}
					}
					//Jump / Double Jump.
					if((rpgCharacterMovementController.canJump || rpgCharacterMovementController.canDoubleJump) && !blockGui && rpgCharacterController.canAction && !navAgentToggle)
					{
						if(rpgCharacterMovementController.MaintainingGround())
						{
							if(GUI.Button(new Rect(25, 175, 100, 30), "Jump"))
							{
								if(rpgCharacterMovementController.canJump)
								{
									rpgCharacterMovementController.currentState = RPGCharacterState.Jump;
									rpgCharacterMovementController.rpgCharacterState = RPGCharacterState.Jump;
								}
							}
						}
						if(rpgCharacterMovementController.canDoubleJump)
						{
							if(GUI.Button(new Rect(25, 175, 100, 30), "Jump Flip"))
							{
								rpgCharacterMovementController.currentState = RPGCharacterState.DoubleJump;
								rpgCharacterMovementController.rpgCharacterState = RPGCharacterState.DoubleJump;
							}
						}
					}
					//NavMesh
					if(!blockGui && rpgCharacterMovementController.MaintainingGround())
					{
						if(rpgCharacterMovementController.navMeshAgent != null)
						{
							useNavAgent = GUI.Toggle(new Rect(500, 15, 100, 30), useNavAgent, "Use NavAgent");
							if(useNavAgent)
							{
								navAgentToggle = true;
								rpgCharacterMovementController.useMeshNav = true;
								rpgCharacterMovementController.navMeshAgent.enabled = true;
								rpgCharacterController.rpgCharacterInputControllerFREE.allowedInput = false;
								GUI.Label(new Rect(500, 45, 220, 50), "Click to move Character.");
							}
							else
							{
								navAgentToggle = false;
								rpgCharacterMovementController.useMeshNav = false;
								rpgCharacterMovementController.navMeshAgent.enabled = false;
								rpgCharacterController.rpgCharacterInputControllerFREE.allowedInput = true;
							}
						}
						else
						{
							rpgCharacterMovementController.useMeshNav = false;
							rpgCharacterController.rpgCharacterInputControllerFREE.allowedInput = true;
						}
					}
				}
				//Death Pickup Activate.
				if(!blockGui && !rpgCharacterController.isBlocking && rpgCharacterMovementController.MaintainingGround() && rpgCharacterController.canAction && !navAgentToggle)
				{
					if(GUI.Button(new Rect(30, 270, 100, 30), "Death"))
					{
						rpgCharacterController.Death();
					}
				}
			}

			//Revive.
			if(rpgCharacterController.isDead)
			{
				if(GUI.Button(new Rect(30, 270, 100, 30), "Revive"))
				{
					rpgCharacterController.Revive();
				}
			}
        }

19 View Source File : EditorGUIHelper.cs
License : MIT License
Project Creator : Hertzole

public static bool DrawHeaderFoldout(string replacedle, bool state)
        {
            Rect backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

            Rect labelRect = backgroundRect;
            labelRect.xMin += 16f;
            labelRect.xMax -= 20f;

            Rect foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;

            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            // Background
            float backgroundTint = EditorGUIUtility.isProSkin ? 0.1f : 1f;
            EditorGUI.DrawRect(backgroundRect, new Color(backgroundTint, backgroundTint, backgroundTint, 0.2f));

            // replacedle
            EditorGUI.LabelField(labelRect, replacedle, EditorStyles.boldLabel);

            // Active checkbox
            state = GUI.Toggle(foldoutRect, state, GUIContent.none, EditorStyles.foldout);

            Event e = Event.current;
            if (e.type == EventType.MouseDown && backgroundRect.Contains(e.mousePosition) && e.button == 0)
            {
                state = !state;
                e.Use();
            }

            return state;
        }

19 View Source File : GUI.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static bool Toggle(Rect position, bool val, string label)
        {
            UGUI.Label(position, label, Style.Label);
            return UGUI.Toggle(new Rect(position.x + position.width - Style.Height, position.y, Style.Height, Style.Height), val, string.Empty, Style.Toggle);
        }

19 View Source File : GUI.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static bool Toggle(SmartRect position, bool val, string label, bool move = false)
        {
            UGUI.Label(position.ToRect(), label, Style.Label);
            position.MoveOffsetX(position.width - Style.Height);
            val = UGUI.Toggle(position.ToRect(), val, string.Empty, Style.Toggle);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }

            return val;
        }

19 View Source File : TimelineTreeView.cs
License : MIT License
Project Creator : BattleDawnNZ

void DrawFoldout(TreeViewItem item, Rect foldoutRect, float indent)
        {
            var showFoldout = m_TreeView.data.IsExpandable(item);
            if (showFoldout)
            {
                foldoutRect.x = indent - kFoldOutOffset;
                foldoutRect.width = m_FoldoutWidth;
                EditorGUI.BeginChangeCheck();
                float foldoutIconHeight = DirectorStyles.Instance.foldout.fixedHeight;
                foldoutRect.y += foldoutIconHeight / 2.0f;
                foldoutRect.height = foldoutIconHeight;

                if (foldoutRect.xMax > m_State.sequencerHeaderWidth)
                    return;

                //Override Disable state for TrakGroup toggle button to expand/collapse group.
                bool previousEnableState = GUI.enabled;
                GUI.enabled = true;
                bool newExpandedValue = GUI.Toggle(foldoutRect, m_TreeView.data.IsExpanded(item), GUIContent.none, m_Styles.foldout);
                GUI.enabled = previousEnableState;

                if (EditorGUI.EndChangeCheck())
                {
                    if (Event.current.alt)
                        m_TreeView.data.SetExpandedWithChildren(item, newExpandedValue);
                    else
                        m_TreeView.data.SetExpanded(item, newExpandedValue);
                }
            }
        }

19 View Source File : EditorUtilities.cs
License : MIT License
Project Creator : huailiang

internal static bool DrawHeader(string replacedle, bool state)
        {
            var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

            var labelRect = backgroundRect;
            labelRect.xMin += 16f;
            labelRect.xMax -= 20f;

            var foldoutRect = backgroundRect;
            foldoutRect.y += 1f;
            foldoutRect.width = 13f;
            foldoutRect.height = 13f;

            // Background rect should be full-width
            backgroundRect.xMin = 0f;
            backgroundRect.width += 4f;

            // Background
            EditorGUI.DrawRect(backgroundRect, Styling.headerBackground);

            // replacedle
            EditorGUI.LabelField(labelRect, GetContent(replacedle), EditorStyles.boldLabel);

            // Foldout
            state = GUI.Toggle(foldoutRect, state, GUIContent.none, EditorStyles.foldout);

            var e = Event.current;
            if (e.type == EventType.MouseDown && backgroundRect.Contains(e.mousePosition) && e.button == 0)
            {
                state = !state;
                e.Use();
            }

            return state;
        }

19 View Source File : TimelineTrackBaseGUI.cs
License : Creative Commons Zero v1.0 Universal
Project Creator : Madalaski

protected void DrawLockButton(Rect rect, WindowState state)
        {
            using (new EditorGUI.DisabledScope(TimelineUtility.IsLockedFromGroup(track)))
            {
                EditorGUI.BeginChangeCheck();
                var isLocked = track.lockedInHierarchy;
                var tooltip = isLocked ? Styles.trackLockBtnOnTooltip : Styles.trackLockBtnOffTooltip;
                var locked = GUI.Toggle(rect, track.lockedInHierarchy, tooltip, TimelineWindow.styles.trackLockButton);
                if (EditorGUI.EndChangeCheck())
                    LockTrack.SetLockState(new[] { track }, locked);
            }
        }