Run-and-capture/Assets/Resources/1/MK/MKToon/Editor/Helper/MKToonIntSliderDrawer.cs
2021-12-15 16:29:44 +03:00

57 lines
2.0 KiB
C#

//////////////////////////////////////////////////////
// MK Toon Editor Int Slider Drawer //
// //
// Created by Michael Kremmel //
// www.michaelkremmel.de //
// Copyright © 2021 All rights reserved. //
//////////////////////////////////////////////////////
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System;
namespace MK.Toon.Editor
{
internal class MKToonIntSliderDrawer : MK.Toon.Editor.MaterialPropertyDrawer
{
public MKToonIntSliderDrawer(GUIContent ui) : base(ui) {}
public MKToonIntSliderDrawer() : base(GUIContent.none) {}
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
{
EditorGUI.showMixedValue = prop.hasMixedValue;
int intValue = (int) prop.floatValue;
EditorGUI.BeginChangeCheck();
intValue = EditorGUI.IntSlider(position, new GUIContent(label, _guiContent.tooltip), intValue, (int) prop.rangeLimits.x, (int) prop.rangeLimits.y);
if (EditorGUI.EndChangeCheck())
{
prop.floatValue = intValue;
}
EditorGUI.showMixedValue = false;
}
}
internal class MKToonLightBandsDrawer : MKToonIntSliderDrawer
{
public MKToonLightBandsDrawer() : base(UI.lightBands) {}
}
internal class MKToonStencilRefDrawer : MKToonIntSliderDrawer
{
public MKToonStencilRefDrawer() : base(UI.stencilRef) {}
}
internal class MKToonStencilReadMaskDrawer : MKToonIntSliderDrawer
{
public MKToonStencilReadMaskDrawer() : base(UI.stencilReadMask) {}
}
internal class MKToonStencilWriteMaskDrawer : MKToonIntSliderDrawer
{
public MKToonStencilWriteMaskDrawer() : base(UI.stencilWriteMask) {}
}
internal class MKToonRenderPriorityDrawer : MKToonIntSliderDrawer
{
public MKToonRenderPriorityDrawer() : base(UI.renderPriority) {}
}
}
#endif