init
This commit is contained in:
commit
001bb14f16
951 changed files with 270074 additions and 0 deletions
8
Assets/Tools/SimpleMinMaxSlider/Scripts/Editor.meta
Normal file
8
Assets/Tools/SimpleMinMaxSlider/Scripts/Editor.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b58f02022de16354ba42b835bcc79d57
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,81 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Geri.MinMaxSlider;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MinMaxSliderAttribute))]
|
||||
public class MinMaxSliderDrawer : PropertyDrawer {
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){
|
||||
|
||||
var minMaxAttribute = (MinMaxSliderAttribute)attribute;
|
||||
var propertyType = property.propertyType;
|
||||
|
||||
label.tooltip = minMaxAttribute.min.ToString("F2") + " to " + minMaxAttribute.max.ToString("F2");
|
||||
|
||||
if(propertyType == SerializedPropertyType.Vector2){
|
||||
Vector2 vector = property.vector2Value;
|
||||
float minVal = vector.x;
|
||||
float maxVal = vector.y;
|
||||
|
||||
int originalIndentLevel = EditorGUI.indentLevel;
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
EditorGUI.indentLevel = 0;
|
||||
float fieldWidth = position.width / 4f - 4f;
|
||||
float sliderWidth = position.width / 2f;
|
||||
position.width = fieldWidth;
|
||||
minVal = EditorGUI.FloatField(position, minVal);
|
||||
position.x += fieldWidth + 4f;
|
||||
position.width = sliderWidth;
|
||||
EditorGUI.MinMaxSlider(position, ref minVal, ref maxVal, minMaxAttribute.min, minMaxAttribute.max);
|
||||
position.x += sliderWidth + 4f;
|
||||
position.width = fieldWidth;
|
||||
maxVal = EditorGUI.FloatField(position, maxVal);
|
||||
if (maxVal < minMaxAttribute.min){
|
||||
minVal = minMaxAttribute.min;
|
||||
}else if (maxVal > minMaxAttribute.max){
|
||||
maxVal = minMaxAttribute.max;
|
||||
}
|
||||
vector = new Vector2(minVal > maxVal ? maxVal : minVal, maxVal);
|
||||
property.vector2Value = vector;
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
EditorGUI.indentLevel = originalIndentLevel;
|
||||
|
||||
}else if(propertyType == SerializedPropertyType.Vector2Int){
|
||||
|
||||
Vector2Int vector = property.vector2IntValue;
|
||||
float minVal = vector.x;
|
||||
float maxVal = vector.y;
|
||||
|
||||
int originalIndentLevel = EditorGUI.indentLevel;
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
EditorGUI.indentLevel = 0;
|
||||
float fieldWidth = position.width / 4f - 4f;
|
||||
float sliderWidth = position.width / 2f;
|
||||
position.width = fieldWidth;
|
||||
minVal = EditorGUI.FloatField(position, minVal);
|
||||
position.x += fieldWidth + 4f;
|
||||
position.width = sliderWidth;
|
||||
EditorGUI.MinMaxSlider(position, ref minVal, ref maxVal, minMaxAttribute.min, minMaxAttribute.max);
|
||||
position.x += sliderWidth + 4f;
|
||||
position.width = fieldWidth;
|
||||
maxVal = EditorGUI.FloatField(position, maxVal);
|
||||
if (maxVal < minMaxAttribute.min){
|
||||
minVal = minMaxAttribute.min;
|
||||
}else if (maxVal > minMaxAttribute.max){
|
||||
maxVal = minMaxAttribute.max;
|
||||
}
|
||||
vector = new Vector2Int(Mathf.FloorToInt(minVal > maxVal ? maxVal : minVal), Mathf.FloorToInt(maxVal));
|
||||
property.vector2IntValue = vector;
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
EditorGUI.indentLevel = originalIndentLevel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6b53f69308943e499e344adc5adee79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
namespace Geri.MinMaxSlider
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public class MinMaxSliderAttribute : PropertyAttribute{
|
||||
|
||||
public float min;
|
||||
public float max;
|
||||
|
||||
public MinMaxSliderAttribute(float min, float max)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a090d8b694abe7141af9c000b8cf42ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue