UnityEngine.GUI.HorizontalSlider(UnityEngine.Rect, float, float, float, UnityEngine.GUIStyle, UnityEngine.GUIStyle)

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

27 Examples 7

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

public static float BombStatSlider(SmartRect position, float value, string label, float offset, float step, float min, float max, bool move = true)
        {
            if (offset > 0f)
            {
                UnityEngine.GUI.Label(position.ToRect(), label, Style.Label);
                position.MoveOffsetX(offset);
            }

            value = UnityEngine.GUI.HorizontalSlider(position.ToRect(), value, min, max, Style.Slider, Style.SliderBody);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }

            if(step == 0.5f)
            {
                int low = Mathf.FloorToInt(value);
                float diff = value - low;
                if (diff >= 0.25f && diff < 0.75f)
                {
                    return low + 0.5f;
                }
                else
                {
                    return Mathf.RoundToInt(value);
                }
            }
            else
            {
                return (int)value;
            }
        }

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

public static float HorizontalSlider(Rect position, float value, string label, float offset)
        {
            if (offset > 0f)
            {
                UGUI.Label(position, label, Style.Label);
                position.x += offset;
                position.width -= offset;
            }
            return UGUI.HorizontalSlider(position, value, 0f, 1f, Style.Slider, Style.SliderBody);
        }

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

public static float HorizontalSlider(Rect position, float value, string label, float min, float max, float offset)
        {
            if (offset > 0f)
            {
                UGUI.Label(position, label, Style.Label);
                position.x += offset;
                position.width -= offset;
            }
            return UGUI.HorizontalSlider(position, value, min, max, Style.Slider, Style.SliderBody);
        }

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

public static void HorizontalSlider(Rect position, Setting<float> value, string label, float offset)
        {
            if (offset > 0f)
            {
                UGUI.Label(position, label, Style.Label);
                position.x += offset;
                position.width -= offset;
            }
            value.Value = UGUI.HorizontalSlider(position, value.Value, 0f, 1f, Style.Slider, Style.SliderBody);
        }

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

public static void HorizontalSlider(Rect position, Setting<float> value, string label, float min, float max, float offset)
        {
            if (offset > 0f)
            {
                UGUI.Label(position, label, Style.Label);
                position.x += offset;
                position.width -= offset;
            }
            value.Value = UGUI.HorizontalSlider(position, value.Value, min, max, Style.Slider, Style.SliderBody);
        }

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

public static float HorizontalSlider(SmartRect position, float value, string label, float offset, bool move = false)
        {
            if (offset > 0f)
            {
                UGUI.Label(position.ToRect(), label, Style.Label);
                position.MoveOffsetX(offset);
            }
            value = UGUI.HorizontalSlider(position.ToRect(), value, 0f, 1f, Style.Slider, Style.SliderBody);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }

            return value;
        }

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

public static float HorizontalSlider(SmartRect position, float value, string label, float min, float max, float offset, bool move = false)
        {
            if (offset > 0f)
            {
                UGUI.Label(position.ToRect(), label, Style.Label);
                position.MoveOffsetX(offset);
            }
            value = UGUI.HorizontalSlider(position.ToRect(), value, min, max, Style.Slider, Style.SliderBody);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }

            return value;
        }

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

public static void HorizontalSlider(SmartRect position, Setting<float> value, string label, float offset, bool move = false)
        {
            if (offset > 0f)
            {
                UGUI.Label(position.ToRect(), label, Style.Label);
                position.MoveOffsetX(offset);
            }
            value.Value = UGUI.HorizontalSlider(position.ToRect(), value.Value, 0f, 1f, Style.Slider, Style.SliderBody);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }
        }

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

public static void HorizontalSlider(SmartRect position, Setting<float> value, string label, float min, float max, float offset, bool move = false)
        {
            if (offset > 0f)
            {
                UGUI.Label(position.ToRect(), label, Style.Label);
                position.MoveOffsetX(offset);
            }
            value.Value = UGUI.HorizontalSlider(position.ToRect(), value.Value, min, max, Style.Slider, Style.SliderBody);
            position.ResetX();
            if (move)
            {
                position.MoveY();
            }
        }

19 View Source File : GUIWindow.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm

public float Slider(float val, float min, float max)
        {
            return GUI.HorizontalSlider(NextControlRect(), val, min, max);
        }

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

protected void OnShapeColorArea(Event guiEvent, Rect guiRect)
	{
		if (testProxy == null)
		{
			testProxy = ScriptableObject.CreateInstance<VectorShape.ShapeProxy>();
			testProxy.name = "Shape";
			//testProxy.hideFlags = HideFlags.HideAndDontSave;
			testProxy.penSize = shapePenSize;
			testProxy.colorOutline = shapeOutlineColor;
			testProxy.colorFill = shapeFillColor;
		}

		// Go right to left
		Rect displayRect = new Rect(guiRect);
		displayRect.height = EditorGUIUtility.singleLineHeight;
		displayRect.y += (guiRect.height - displayRect.height) / 2f;
		displayRect.width -= toolbarPadding;
		Rect fillColorRect = new Rect(displayRect);
		fillColorRect.width = colorChooserWidth;
		fillColorRect.x = displayRect.xMax - fillColorRect.width;
		Rect fillLabelRect = new Rect(displayRect);
		fillLabelRect.width = fillLabelWidth;
		fillLabelRect.x = fillColorRect.x - fillLabelRect.width;

		Rect penColorRect = new Rect(displayRect);
		penColorRect.width = colorChooserWidth;
		penColorRect.x = fillLabelRect.x - penColorRect.width - toolbarPadding;
		Rect penSizeRect = new Rect(displayRect);
		penSizeRect.width = penSizeWidth;
		penSizeRect.x = penColorRect.x - penSizeRect.width - toolbarPadding;
		Rect penLabelRect = new Rect(displayRect);
		penLabelRect.width = penLabelWidth;
		penLabelRect.x = penSizeRect.x - penLabelRect.width;

		GUIStyle rightJustified = new GUIStyle(GUI.skin.label);
		rightJustified.alignment = TextAnchor.MiddleRight;

		SerializedObject propertyObject = new SerializedObject(testProxy);
		EditorGUI.BeginChangeCheck();

		EditorGUI.LabelField(penLabelRect, penLabelContent, rightJustified);
		SerializedProperty penSize = propertyObject.FindProperty("penSize");
		SerializedProperty colorOutline = propertyObject.FindProperty("colorOutline");
		penSize.floatValue = GUI.HorizontalSlider(penSizeRect, penSize.floatValue, 0f, 25f);
		colorOutline.colorValue = EditorGUI.ColorField(penColorRect, GUIContent.none, colorOutline.colorValue, false, true, false);

		EditorGUI.LabelField(fillLabelRect, fillLabelContent, rightJustified);
		SerializedProperty colorFill = propertyObject.FindProperty("colorFill");
		colorFill.colorValue = EditorGUI.ColorField(fillColorRect, GUIContent.none, colorFill.colorValue, false, true, false);

		if (EditorGUI.EndChangeCheck() || propertyObject.hasModifiedProperties)
		{
			propertyObject.ApplyModifiedProperties();
			propertyObject.Update();

			shapePenSize = testProxy.penSize;
			shapeOutlineColor = testProxy.colorOutline;
			shapeFillColor = testProxy.colorFill;
		}
		//EditorGUI.BeginChangeCheck();
		//EditorGUI.LabelField(penLabelRect, penLabelContent);
		//shapePenSize = EditorGUI.DelayedFloatField(penSizeRect, shapePenSize);

		//shapeOutlineColor = EditorGUI.ColorField(penColorRect, GUIContent.none, shapeOutlineColor, false, true, false);

		//EditorGUI.LabelField(fillLabelRect, fillLabelContent);
		//shapeFillColor = EditorGUI.ColorField(fillColorRect, GUIContent.none, shapeFillColor, false, true, false);

		//if (EditorGUI.EndChangeCheck())
		//{
		//}

	}

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

void DrawWheel(ref Vector4 value, bool overrideState, TrackballAttribute attr)
        {
            var wheelRect = GUILayoutUtility.GetAspectRect(1f);
            float size = wheelRect.width;
            float hsize = size / 2f;
            float radius = 0.38f * size;

            Vector3 hsv;
            Color.RGBToHSV(value, out hsv.x, out hsv.y, out hsv.z);
            float offset = value.w;

            // Thumb
            var thumbPos = Vector2.zero;
            float theta = hsv.x * (Mathf.PI * 2f);
            thumbPos.x = Mathf.Cos(theta + (Mathf.PI / 2f));
            thumbPos.y = Mathf.Sin(theta - (Mathf.PI / 2f));
            thumbPos *= hsv.y * radius;

            // Draw the wheel
            if (Event.current.type == EventType.Repaint)
            {
                // Retina support
                float scale = EditorGUIUtility.pixelsPerPoint;

                if (s_Material == null)
                    s_Material = new Material(Shader.Find("Hidden/PostProcessing/Editor/Trackball")) { hideFlags = HideFlags.HideAndDontSave };

                // Wheel texture
            #if UNITY_2018_1_OR_NEWER
                const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.sRGB;
            #else
                const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.Linear;
            #endif

                var oldRT = RenderTexture.active;
                var rt = RenderTexture.GetTemporary((int)(size * scale), (int)(size * scale), 0, RenderTextureFormat.ARGB32, kReadWrite);
                s_Material.SetFloat("_Offset", offset);
                s_Material.SetFloat("_DisabledState", overrideState ? 1f : 0.5f);
                s_Material.SetVector("_Resolution", new Vector2(size * scale, size * scale / 2f));
                Graphics.Blit(null, rt, s_Material, EditorGUIUtility.isProSkin ? 0 : 1);
                RenderTexture.active = oldRT;

                GUI.DrawTexture(wheelRect, rt);
                RenderTexture.ReleaseTemporary(rt);

                var thumbSize = Styling.wheelThumbSize;
                var thumbSizeH = thumbSize / 2f;
                Styling.wheelThumb.Draw(new Rect(wheelRect.x + hsize + thumbPos.x - thumbSizeH.x, wheelRect.y + hsize + thumbPos.y - thumbSizeH.y, thumbSize.x, thumbSize.y), false, false, false, false);
            }

            // Input
            var bounds = wheelRect;
            bounds.x += hsize - radius;
            bounds.y += hsize - radius;
            bounds.width = bounds.height = radius * 2f;
            hsv = GetInput(bounds, hsv, thumbPos, radius);
            value = Color.HSVToRGB(hsv.x, hsv.y, 1f);
            value.w = offset;

            // Offset
            var sliderRect = GUILayoutUtility.GetRect(1f, 17f);
            float padding = sliderRect.width * 0.05f; // 5% padding
            sliderRect.xMin += padding;
            sliderRect.xMax -= padding;
            value.w = GUI.HorizontalSlider(sliderRect, value.w, -1f, 1f);

            if (attr.mode == TrackballAttribute.Mode.None)
                return;

            // Values
            var displayValue = Vector3.zero;

            switch (attr.mode)
            {
                case TrackballAttribute.Mode.Lift: displayValue = ColorUtilities.ColorToLift(value);
                    break;
                case TrackballAttribute.Mode.Gamma: displayValue = ColorUtilities.ColorToInverseGamma(value);
                    break;
                case TrackballAttribute.Mode.Gain: displayValue = ColorUtilities.ColorToGain(value);
                    break;
            }

            using (new EditorGUI.DisabledGroupScope(true))
            {
                var valuesRect = GUILayoutUtility.GetRect(1f, 17f);
                valuesRect.width /= 3f;
                GUI.Label(valuesRect, displayValue.x.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
                valuesRect.x += valuesRect.width;
                GUI.Label(valuesRect, displayValue.y.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
                valuesRect.x += valuesRect.width;
                GUI.Label(valuesRect, displayValue.z.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
                valuesRect.x += valuesRect.width;
            }
        }

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

private void OnGUI()
    {
        val = GUI.HorizontalSlider(rect, val, 0f, 1f);
        hud.UpdateHud(val);
    }

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

void OnWheelGUI(Rect position, int size, SerializedProperty property)
        {
            if (Event.current.type == EventType.Layout)
                return;

            var value = property.colorValue;
            float offset = value.a;

            var wheelDrawArea = position;
            wheelDrawArea.height = size;

            if (wheelDrawArea.width > wheelDrawArea.height)
            {
                wheelDrawArea.x += (wheelDrawArea.width - wheelDrawArea.height) / 2.0f;
                wheelDrawArea.width = position.height;
            }

            wheelDrawArea.width = wheelDrawArea.height;

            float hsize = size / 2f;
            float radius = 0.38f * size;
            Vector3 hsv;
            Color.RGBToHSV(value, out hsv.x, out hsv.y, out hsv.z);

            if (Event.current.type == EventType.Repaint)
            {
                float scale = EditorGUIUtility.pixelsPerPoint;

                // Wheel texture
                var oldRT = RenderTexture.active;
                var rt = RenderTexture.GetTemporary((int)(size * scale), (int)(size * scale), 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
                s_Material.SetFloat("_Offset", offset);
                s_Material.SetFloat("_DisabledState", GUI.enabled ? 1f : 0.5f);
                s_Material.SetVector("_Resolution", new Vector2(size * scale, size * scale / 2f));
                Graphics.Blit(null, rt, s_Material, EditorGUIUtility.isProSkin ? 0 : 1);
                RenderTexture.active = oldRT;

                GUI.DrawTexture(wheelDrawArea, rt);
                RenderTexture.ReleaseTemporary(rt);

                // Thumb
                var thumbPos = Vector2.zero;
                float theta = hsv.x * (Mathf.PI * 2f);
                float len = hsv.y * radius;
                thumbPos.x = Mathf.Cos(theta + (Mathf.PI / 2f));
                thumbPos.y = Mathf.Sin(theta - (Mathf.PI / 2f));
                thumbPos *= len;
                var thumbSize = FxStyles.wheelThumbSize;
                var thumbSizeH = thumbSize / 2f;
                FxStyles.wheelThumb.Draw(new Rect(wheelDrawArea.x + hsize + thumbPos.x - thumbSizeH.x, wheelDrawArea.y + hsize + thumbPos.y - thumbSizeH.y, thumbSize.x, thumbSize.y), false, false, false, false);
            }

            var bounds = wheelDrawArea;
            bounds.x += hsize - radius;
            bounds.y += hsize - radius;
            bounds.width = bounds.height = radius * 2f;
            hsv = GetInput(bounds, hsv, radius);
            value = Color.HSVToRGB(hsv.x, hsv.y, 1f);
            value.a = offset;

            // Luminosity booster
            position = wheelDrawArea;
            float oldX = position.x;
            float oldW = position.width;
            position.y += position.height + 4f;
            position.x += (position.width - (position.width * 0.75f)) / 2f;
            position.width = position.width * 0.75f;
            position.height = EditorGUIUtility.singleLineHeight;
            value.a = GUI.HorizontalSlider(position, value.a, -1f, 1f);

            // Advanced controls
            var data = Vector3.zero;

            if (TryGetDisplayValue(value, property, out data))
            {
                position.x = oldX;
                position.y += position.height;
                position.width = oldW / 3f;

                using (new EditorGUI.DisabledGroupScope(true))
                {
                    GUI.Label(position, data.x.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
                    position.x += position.width;
                    GUI.Label(position, data.y.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
                    position.x += position.width;
                    GUI.Label(position, data.z.ToString("F2"), EditorStyles.centeredGreyMiniLabel);
                    position.x += position.width;
                }
            }

            // replacedle
            position.x = oldX;
            position.y += position.height;
            position.width = oldW;
            GUI.Label(position, property.displayName, EditorStyles.centeredGreyMiniLabel);

            if (m_ResetState)
            {
                value = Color.clear;
                m_ResetState = false;
            }

            property.colorValue = value;
        }

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

private Rect DrawPreview(Rect parent) {
        Vector2 offset = new Vector2(20, 20);

        // PREVIEW RECT
        Vector2 previewLocalPosition = new Vector2(offset.x, offset.y);
        Vector2 previewDimension = new Vector2(parent.width - offset.x * 2, parent.width - offset.x * 2);
        Rect previewRect = new Rect(previewLocalPosition, previewDimension);

        // FPS COUNTER RECT
        Vector2 fpsLocalPosition = new Vector2(previewRect.x, previewRect.yMax);
        Vector2 fpsDimension = new Vector2(40, 20);
        Rect fpsRect = new Rect(fpsLocalPosition, fpsDimension);

        // SLIDER RECT
        Vector2 speedSliderLocalPosition = new Vector2(fpsRect.xMax, previewRect.yMax);
        Vector2 speedSliderDimension = new Vector2(previewRect.width - fpsRect.width, 20);
        Rect speedSliderRect = new Rect(speedSliderLocalPosition, speedSliderDimension);

        // BG RECT
       
        Rect previewBGRect = new Rect(previewRect.x - offset.x / 2, previewRect.y - offset.y / 2, previewRect.width + offset.x,
            previewRect.height + speedSliderRect.height + offset.y / 2);

        // EXTEND WINDOW RECT
        Vector2 extendWindowRectOffset = new Vector2(5, 5);
        float extendWindowRectWidth = 24;
        float extendWindowRectHeight = 24;
        Rect extendWindowRect = new Rect(previewRect.xMax - extendWindowRectWidth - extendWindowRectOffset.x, 
            previewRect.yMax - extendWindowRectHeight - extendWindowRectOffset.y, extendWindowRectWidth, extendWindowRectHeight);

        // DRAWING STUFF
        GUI.DrawTexture(previewBGRect, blackBarBG);
        EditorGUI.DrawTextureTransparent(previewRect,PIAAnimator.Instance.GetFrameOrFirst().GetFrameTexture());
        GUI.Label(fpsRect, PIAAnimator.Instance.Speed + " FPS", skin.GetStyle("fpscounter"));
        PIAAnimator.Instance.Speed = (int)GUI.HorizontalSlider(speedSliderRect, PIAAnimator.Instance.Speed, 0, 24);
        if (PIAInputArea.IsMouseInsideRect(previewBGRect))
        {
            if (GUI.Button(extendWindowRect, GUIContent.none,skin.GetStyle("extendpreview")))
                PIAExtendedPreviewWindow.ShowWindow();
            Rect extendWindowGlobalRect = PIATooltipUtility.ChildToGlobalRect(extendWindowRect, parent);
            Rect extendWindowTooltipRect = new Rect(0, 0, 105, 22.5f);
            PIATooltip extendWindowTooltip = new PIATooltip(extendWindowTooltipRect, "Extend preview");
            PIATooltip.SetPositionPreset(ref extendWindowTooltip, extendWindowGlobalRect, PIATooltip.PIATooltipPreset.Down);
            PIATooltipUtility.AddTooltip(extendWindowGlobalRect, extendWindowTooltip);
        }
        


        return previewBGRect;
    }

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

void OnGUI()
	{
	    GUI.Box(new Rect(10, 10, 200, 100), "Player Machine");

        GUI.TextField(new Rect(20, 40, 180, 20), string.Format("State: {0}", playerMachine.currentState));
        timeScale = GUI.HorizontalSlider(new Rect(20, 70, 180, 20), timeScale, 0.0f, 1.0f);

        Time.timeScale = timeScale;
	}

19 View Source File : DemoGUI.cs
License : MIT License
Project Creator : PacktPublishing

void OnGUI()
    {
        if (m_ARController == null || !m_ARController.enabled)
            return;

        guiHeight = Screen.height / 5;
        var buttonWidth = Screen.width / 2;

        if (GUI.Button(new Rect(Screen.width - buttonWidth, Screen.height - guiHeight, buttonWidth, guiHeight), "Fire!", m_GuiSkin.button))
            m_ObjectShooter.RequestFire(new Vector2(Screen.width / 2, Screen.height / 2));

        var sliderWidth = Screen.width / 2;
        var sliderHeight = guiHeight / 2;
        var angle = GUI.HorizontalSlider(
            new Rect(0, Screen.height - sliderHeight * 2, sliderWidth, sliderHeight),
            m_RotationAngle, 0f, 360f,
            m_GuiSkin.horizontalSlider,
            m_GuiSkin.horizontalSliderThumb);

        if (angle != m_RotationAngle)
        {
            m_ARController.rotation = Quaternion.AngleAxis(m_RotationAngle, Vector3.up);
            m_RotationAngle = angle;
        }

        var scale = GUI.HorizontalSlider(
            new Rect(0, Screen.height - sliderHeight, sliderWidth, sliderHeight),
            m_ARController.scale, 1f, 100f,
            m_GuiSkin.horizontalSlider,
            m_GuiSkin.horizontalSliderThumb);

        if (scale != m_ARController.scale)
            m_ARController.scale = scale;
    }

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 : 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 : Menu.cs
License : MIT License
Project Creator : ThePotato97

private static void lobbyActions()
        {
            GUI.SetNextControlName("changename");
            playerNickName = GUI.TextArea(new Rect(320f, 25f, 200f, 20f), playerNickName);
            if (GUI.Button(new Rect(320f, 45f, 200f, 20f), "Change Name"))
            {
                GUI.FocusControl("changename");
                PhotonNetwork.NickName = playerNickName;
            }

            if (GUI.Button(new Rect(320f, 145f, 200f, 20f), "Force Start"))
            {
                Main.serverManager.StartGame();
            }

            if (GUI.Button(new Rect(520f, 50f, 200f, 20f), "Add 100$"))
            {
                FileBasedPrefs.SetInt("PlayersMoney", FileBasedPrefs.GetInt("PlayersMoney", 0) + 100);
            }
            if (GUI.Button(new Rect(520f, 75f, 200f, 20f), "Add 1 Level"))
            {
                FileBasedPrefs.SetInt("myTotalExp", FileBasedPrefs.GetInt("myTotalExp", 0) + 100);
            }
            playerReach = GUI.HorizontalSlider(new Rect(320, 200f, 200f, 20f), (float)((int)playerReach), 1.6f, 16f);
            GUI.Label(new Rect(10f, 160f, 200, 20f), "Reach: " + (int)playerReach);
            if (GUI.Button(new Rect(320f, 225f, 200f, 20f), "Click to change reach"))
            {
                MyPlayer = Main.GetLocalPlayer();
                MyPlayer.field_Public_PCPropGrab_0.field_Private_Single_0 = playerReach;
            }
            //GUI.Label(new Rect(920f, 0f, 200f, 20f), "Join Room:");
            //roomName = GUI.TextArea(new Rect(920f, 25f, 200f, 20f), roomName);
            //steamID = GUI.TextArea(new Rect(920f, 50f, 200f, 20f), steamID);
            //if (GUI.Button(new Rect(920f, 75f, 200f, 20f), "Join Room by Name"))
            //{
            //    PhotonNetwork.JoinRoom(roomName);
            //}
            //if (GUI.Button(new Rect(920f, 100f, 200f, 20f), "Join Room by ID"))
            //{
            //    object[] FriendIDList;

            //    bool test = PhotonNetwork.FindFriends(new string[]
            //    {
            //            steamID
            //    });
            //    MelonLogger.Log("steamID = " + steamID);
            //    //foreach (FriendInfo friendInfo in PhotonNetwork.Friends)
            //    //{
            //    //PhotonNetwork.JoinRoom(friendInfo.Room);
            //    //}
            //}
        }

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

public void OnSceneGUI()
        {
            Color oldColor = Handles.color;

            m_CollisionMeshMaterial.mainTexture = m_PaintTexture;
            m_CollisionMeshMaterial.color = m_BaseArea.Color;
            Handles.DrawAAPolyLine(3, 5, new[]
            {
                m_Behavior.transform.TransformPoint(new Vector3(-1.0f, -1.0f, -0.1f)),
                m_Behavior.transform.TransformPoint(new Vector3( 1.0f, -1.0f, -0.1f)),
                m_Behavior.transform.TransformPoint(new Vector3( 1.0f,  1.0f, -0.1f)),
                m_Behavior.transform.TransformPoint(new Vector3(-1.0f,  1.0f, -0.1f)),
                m_Behavior.transform.TransformPoint(new Vector3(-1.0f, -1.0f, -0.1f))
            });

            Handles.BeginGUI();
            Color oldGuiColor = GUI.color;
            switch (s_PaintMode)
            {
                case PaintMode.Painting:
                    GUI.color = Color.green;
                    if (GUI.Button(new Rect(0, 0, 100, 25), "Paint Mode"))
                    {
                        s_PaintMode = PaintMode.Erasing;
                    }

                    break;
                case PaintMode.Erasing:
                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(0, 0, 100, 25), "Erase Mode"))
                    {
                        s_PaintMode = PaintMode.Painting;
                    }

                    break;
            }

            GUI.color = Color.black;
            GUI.Label(new Rect(110, 0, 150, 25), string.Format("Brush Size: {0}", s_BrushSize));
            GUI.color = oldGuiColor;

            s_BrushSize = GUI.HorizontalSlider(new Rect(110, 10, 150, 25), s_BrushSize, 1.0f, 20.0f);

            Handles.EndGUI();

            // for some reason we get a zero pixel height or pixel width during editing so ignore it
            if (Camera.current.pixelHeight == 0 || Camera.current.pixelWidth == 0)
            {
                return;
            }

            Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            RaycastHit hit;
            bool ireplaced = Physics.Raycast(ray, out hit);
            if (ireplaced)
            {
                Handles.color = m_BaseArea.Color;
                Handles.DrawWireDisc(hit.point, hit.normal, s_BrushSize);
                Handles.DrawSolidDisc(hit.point, hit.normal, 0.5f);
            }

            switch (Event.current.type)
            {
                case EventType.MouseDown:
                    if (Event.current.button == 0 && !Event.current.alt && !Event.current.shift && !Event.current.control)
                    {
                        if (ireplaced)
                        {
                            GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Preplacedive);

                            m_Painting = true;

                            DrawBrush(hit.textureCoord);

                            Event.current.Use();
                        }
                    }

                    break;
                case EventType.MouseUp:
                    if (m_Painting)
                    {
                        GUIUtility.hotControl = 0;
                        if (ireplaced)
                        {
                            DrawBrush(hit.textureCoord);
                            Event.current.Use();
                        }

                        RegenerateMesh();
                        m_Painting = false;
                    }

                    break;
                case EventType.MouseDrag:
                    if (m_Painting)
                    {
                        if (ireplaced)
                        {
                            DrawBrush(hit.textureCoord);
                            Event.current.Use();
                        }
                    }

                    break;
            }

            SceneView.RepaintAll();
            Handles.color = oldColor;
        }

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

void OnSceneGUI()
        {
            Color oldColor = Handles.color;

            m_CollisionMeshMaterial.mainTexture = m_PaintTexture;
            m_CollisionMeshMaterial.color = m_WalkableArea.m_color;
            Handles.DrawAAPolyLine(3, 5, new[]
            {
                m_WalkableArea.transform.TransformPoint(new Vector3(-1.0f, -0.1f, -1.0f)),
                m_WalkableArea.transform.TransformPoint(new Vector3(1.0f, -0.1f, -1.0f)),
                m_WalkableArea.transform.TransformPoint(new Vector3(1.0f, -0.1f, 1.0f)),
                m_WalkableArea.transform.TransformPoint(new Vector3(-1.0f, -0.1f, 1.0f)),
                m_WalkableArea.transform.TransformPoint(new Vector3(-1.0f, -0.1f, -1.0f))
            });

            Handles.BeginGUI();
            Color oldGuiColor = GUI.color;
            switch (s_PaintMode)
            {
                case PaintMode.Painting:
                    GUI.color = Color.green;
                    if (GUI.Button(new Rect(0, 0, 100, 25), "Paint Mode"))
                    {
                        s_PaintMode = PaintMode.Erasing;
                    }

                    break;
                case PaintMode.Erasing:
                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(0, 0, 100, 25), "Erase Mode"))
                    {
                        s_PaintMode = PaintMode.Painting;
                    }

                    break;
            }

            if (m_Modified)
            {
                GUI.color = Color.cyan;
                if (GUI.Button(new Rect(0, 25, 100, 25), "Bake"))
                {
                    RegenerateMesh();
                }
            }

            GUI.color = Color.black;
            GUI.Label(new Rect(110, 0, 150, 25), string.Format("Brush Size: {0}", s_BrushSize));
            GUI.color = oldGuiColor;

            s_BrushSize = GUI.HorizontalSlider(new Rect(110, 10, 150, 25), s_BrushSize, 1.0f, 20.0f);

            Handles.EndGUI();

            // for some reason we get a zero pixel height or pixel width during editing so ignore it
            if (Camera.current.pixelHeight == 0 || Camera.current.pixelWidth == 0)
            {
                return;
            }

            Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            RaycastHit hit;
            bool ireplaced = Physics.Raycast(ray, out hit);
            if (ireplaced)
            {
                Handles.color = new Color(m_WalkableArea.m_color.r, m_WalkableArea.m_color.g, m_WalkableArea.m_color.b);
                Handles.DrawWireDisc(hit.point, hit.normal, s_BrushSize);
                Handles.DrawSolidDisc(hit.point, hit.normal, 0.5f);
            }

            switch (Event.current.type)
            {
                case EventType.MouseDown:
                    if (Event.current.button == 0 && !Event.current.alt && !Event.current.shift && !Event.current.control)
                    {
                        if (ireplaced)
                        {
                            GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Preplacedive);

                            m_Painting = true;

                            DrawBrush(hit.textureCoord);

                            Event.current.Use();
                        }
                    }

                    break;
                case EventType.MouseUp:
                    if (m_Painting)
                    {
                        GUIUtility.hotControl = 0;
                        if (ireplaced)
                        {
                            DrawBrush(hit.textureCoord);
                            Event.current.Use();
                        }

                        m_Modified = true;
                        m_Painting = false;
                    }

                    break;
                case EventType.MouseDrag:
                    if (m_Painting)
                    {
                        if (ireplaced)
                        {
                            DrawBrush(hit.textureCoord);
                            Event.current.Use();
                        }
                    }

                    break;
            }

            SceneView.RepaintAll();
            Handles.color = oldColor;
        }

19 View Source File : RTEditorGUI.cs
License : MIT License
Project Creator : wqaetly

public static int MathPowerSliderRaw (GUIContent label, int baseValue, int power, int minPow, int maxPow, params GUILayoutOption[] options)
		{
			Rect totalPos = GetSliderRect (label, GUI.skin.label, options);
			Rect sliderFieldPos = PrefixLabel (totalPos, 0.5f, label, GUI.skin.label);

			power = Mathf.RoundToInt (GUI.HorizontalSlider (GetSliderRect (sliderFieldPos), power, minPow, maxPow));
			GUI.Label (GetSliderFieldRect (sliderFieldPos), Mathf.Pow (baseValue, power).ToString ());
			return power;
		}

19 View Source File : RTEditorGUI.cs
License : MIT License
Project Creator : wqaetly

public static float Slider (GUIContent label, float value, float minValue, float maxValue, params GUILayoutOption[] options) 
		{
			#if UNITY_EDITOR
			if (!Application.isPlaying)
				return UnityEditor.EditorGUILayout.Slider (label, value, minValue, maxValue, options);
			#endif

			Rect totalPos = GetSliderRect (label, GUI.skin.label, options);
			Rect sliderFieldPos = PrefixLabel (totalPos, 0.5f, label, GUI.skin.label);

			value = GUI.HorizontalSlider (GetSliderRect (sliderFieldPos), value, minValue, maxValue);
			value = Mathf.Min (maxValue, Mathf.Max (minValue, FloatField (GetSliderFieldRect (sliderFieldPos), value, GUILayout.Width (60))));
			return value;
		}

19 View Source File : RTEditorGUI.cs
License : MIT License
Project Creator : wqaetly

public static int OptionSlider (GUIContent label, int selected, string[] selectableOptions, GUIStyle style, params GUILayoutOption[] options)
		{
			if (style == null) style = GUI.skin.textField;
			Rect totalPos = GetSliderRect (label, style, options);
			Rect sliderFieldPos = PrefixLabel (totalPos, 0.5f, label, GUI.skin.label);

			selected = Mathf.RoundToInt (GUI.HorizontalSlider (GetSliderRect (sliderFieldPos), selected, 0, selectableOptions.Length-1));
			GUI.Label (GetSliderFieldRect (sliderFieldPos), selectableOptions[selected]);
			return selected;
		}

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

public static float ProgressBar(Rect _rect, float _value, float _minLimit, float _maxLimit, string _text, bool _dragable = true, bool _drawMinMax = false)
        {
            float progress = (_value - _minLimit) / (_maxLimit - _minLimit);

            Rect r = _rect;
            GUI.Box(r, string.Empty);
            r.width = _rect.width * progress;
            EditorGUI.DrawRect(r, new Color(0.07f, 0.56f, 0.9f, 1));

            if (_drawMinMax)
            {
                EditorGUI.LabelField(_rect, _minLimit.ToString());
                EditorGUI.LabelField(_rect, _maxLimit.ToString(), EditorStylesExtension.RightLabelStyle);
            }
            EditorGUI.LabelField(_rect, _text, EditorStylesExtension.MiddleLabelStyle);

            if (_dragable)
#if UNITY_2019_1_OR_NEWER
                return GUI.HorizontalSlider(_rect, _value, _minLimit, _maxLimit, EditorStylesExtension.Transparent, EditorStylesExtension.Transparent, EditorStylesExtension.Transparent);
#else
                return GUI.HorizontalSlider(_rect, _value, _minLimit, _maxLimit, EditorStylesExtension.Transparent, EditorStylesExtension.Transparent);
#endif
            return _value;
        }

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

float PreviewSlider(Rect rect, float val, float snapThreshold)
        {
            val = GUI.HorizontalSlider(rect, val, 0.1f, 2.0f, s_Styles.preSlider,
                s_Styles.preSliderThumb); //, GUILayout.MaxWidth(64));
            if (val > 0.25f - snapThreshold && val < 0.25f + snapThreshold)
                val = 0.25f;
            else if (val > 0.5f - snapThreshold && val < 0.5f + snapThreshold)
                val = 0.5f;
            else if (val > 0.75f - snapThreshold && val < 0.75f + snapThreshold)
                val = 0.75f;
            else if (val > 1.0f - snapThreshold && val < 1.0f + snapThreshold)
                val = 1.0f;
            else if (val > 1.25f - snapThreshold && val < 1.25f + snapThreshold)
                val = 1.25f;
            else if (val > 1.5f - snapThreshold && val < 1.5f + snapThreshold)
                val = 1.5f;
            else if (val > 1.75f - snapThreshold && val < 1.75f + snapThreshold)
                val = 1.75f;

            return val;
        }