Added Feel plugin

This commit is contained in:
journaliciouz
2025-12-11 14:49:16 +01:00
parent 97dce4aaf6
commit 1942a531d4
2820 changed files with 257786 additions and 9 deletions

View File

@@ -0,0 +1,28 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMSpringColor))]
class MMSpringColorPropertyDrawer : PropertyDrawer
{
protected float _lastTarget;
protected float _max;
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
SerializedProperty _colorSpring = property.FindPropertyRelative("ColorSpring");
root.Add(new PropertyField(_colorSpring));
return root;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4d274a27f7628664db49fa023801aa2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/Editor/Springs/MMSpringColorPropertyDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,71 @@
using MoreMountains.Tools;
using UnityEditor;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMSpringDebug))]
public class MMSpringDebugPropertyDrawer : PropertyDrawer
{
protected Color _backgroundBarColor = new Color(0f, 0f, 0f, 0.3f);
protected Color _frontBarColor = MMColors.Yellow;
protected SerializedProperty _currentValue;
protected SerializedProperty _targetValue;
protected Rect _rect;
protected float _lastTarget;
protected float _max;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_currentValue = property.FindPropertyRelative("CurrentValue");
_targetValue = property.FindPropertyRelative("TargetValue");
EditorGUI.BeginProperty(position, label, property);
EditorGUI.BeginDisabledGroup(true);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
_rect.x = position.x;
_rect.y = position.y;
_rect.width = position.width;
_rect.height = position.height;
EditorGUI.DrawRect(_rect, _backgroundBarColor);
if (Application.isPlaying)
{
float current = _currentValue.floatValue;
float target = _targetValue.floatValue;
float normalizedValue = 0f;
float diff = target - current;
if (Mathf.Abs(diff) > Mathf.Abs(_max))
{
_max = diff;
}
if (_lastTarget != target)
{
_max = diff;
}
normalizedValue = MMMaths.Remap(diff, -_max, _max, -1f, 1f);
float newWidth = MMMaths.Remap(normalizedValue, -1f, 1f, -position.width/2f, position.width/2f);
_rect.x = position.x + (position.width/2f);
_rect.y = position.y;
_rect.width = newWidth;
_rect.height = position.height;
EditorGUI.DrawRect(_rect, _frontBarColor);
_lastTarget = target;
}
EditorGUI.indentLevel = indent;
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 35b7126fb201e074ea5a3421ba27c5b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/Editor/Springs/MMSpringDebugPropertyDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,67 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMSpringFloat))]
class MMSpringFloatPropertyDrawer : PropertyDrawer
{
protected float _lastTarget;
protected float _max;
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
root.style.backgroundColor = new StyleColor(new Color(255,255,255,0.03f));
root.style.marginTop = 5;
root.style.paddingRight = 5;
SerializedProperty _damping = property.FindPropertyRelative("Damping");
SerializedProperty _frequency = property.FindPropertyRelative("Frequency");
SerializedProperty _unifiedSpring = property.FindPropertyRelative("UnifiedSpring");
SerializedProperty _springDebug = property.FindPropertyRelative("SpringDebug");
root.Add(new PropertyField(_damping));
root.Add(new PropertyField(_frequency));
if (!_unifiedSpring.boolValue)
{
SerializedProperty _clampSettings = property.FindPropertyRelative("ClampSettings");
root.Add(new PropertyField(_clampSettings));
}
if (Application.isPlaying && !_unifiedSpring.boolValue)
{
VisualElement horizontalLayout = new VisualElement();
horizontalLayout.style.flexDirection = FlexDirection.Row;
root.Add(horizontalLayout);
FloatField currentValue = new FloatField("CurrentValue") { bindingPath = "CurrentValueDisplay", isReadOnly = true, style = { flexGrow = 1, paddingRight = 10 } };
currentValue.SetEnabled(false);
currentValue.AddToClassList("mm-fixed-width-floatfield");
horizontalLayout.Add(currentValue);
FloatField targetValue = new FloatField("TargetValue") { bindingPath = "TargetValueDisplay", isReadOnly = true, style = { flexGrow = 1} };
targetValue.SetEnabled(false);
targetValue.AddToClassList("mm-fixed-width-floatfield");
horizontalLayout.Add(targetValue);
FloatField velocity = new FloatField("Velocity") { bindingPath = "VelocityDisplay", isReadOnly = true, style = { flexGrow = 1, paddingLeft = 10} };
velocity.SetEnabled(false);
velocity.AddToClassList("mm-fixed-width-floatfield");
horizontalLayout.Add(velocity);
root.Add(new PropertyField(_springDebug));
}
return root;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: de1ae83f81ca8aa4ea1a8f2fa8b5a8b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/Editor/Springs/MMSpringFloatPropertyDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,81 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMSpringVector2))]
class MMSpringVector2PropertyDrawer : PropertyDrawer
{
protected float _lastTarget;
protected float _max;
protected PropertyField _unifiedSpringField;
protected Label _springXLabel;
protected PropertyField _springXField;
protected Label _springYLabel;
protected PropertyField _springYField;
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
SerializedProperty _separateAxis = property.FindPropertyRelative("SeparateAxis");
SerializedProperty _unifiedSpring = property.FindPropertyRelative("UnifiedSpring");
SerializedProperty _springX = property.FindPropertyRelative("SpringX");
SerializedProperty _springY = property.FindPropertyRelative("SpringY");
Toggle boolToggle = new Toggle("SeparateAxis") { value = property.FindPropertyRelative("SeparateAxis").boolValue };
boolToggle.RegisterValueChangedCallback(evt =>
{
property.FindPropertyRelative("SeparateAxis").boolValue = evt.newValue;
ToggleFields(evt.newValue);
_separateAxis.serializedObject.ApplyModifiedProperties();
});
root.Add(boolToggle);
_unifiedSpringField = new PropertyField(_unifiedSpring);
_springXLabel = new Label("Spring X");
_springXLabel.style.backgroundColor = new StyleColor(new Color(255,0,0,0.2f));
_springXLabel.style.marginLeft = -10;
_springXLabel.style.paddingLeft = 14;
_springXLabel.style.paddingBottom = 3;
_springXLabel.style.paddingTop = 3;
_springXField = new PropertyField(_springX);
_springYLabel = new Label("Spring Y");
_springYLabel.style.backgroundColor = new StyleColor(new Color(0,255,0,0.1f));
_springYLabel.style.marginLeft = -10;
_springYLabel.style.paddingLeft = 14;
_springYLabel.style.paddingBottom = 3;
_springYLabel.style.paddingTop = 3;
_springYField = new PropertyField(_springY);
root.Add(_unifiedSpringField);
root.Add(_springXLabel);
root.Add(_springXField);
root.Add(_springYLabel);
root.Add(_springYField);
ToggleFields(boolToggle.value);
return root;
}
private void ToggleFields(bool show)
{
_unifiedSpringField.style.display = show ? DisplayStyle.None : DisplayStyle.Flex;
_springXLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springXField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springYLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springYField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8ce385a1b7b20b9489103d52d3105023
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/Editor/Springs/MMSpringVector2PropertyDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,97 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMSpringVector3))]
class MMSpringVector3PropertyDrawer : PropertyDrawer
{
protected float _lastTarget;
protected float _max;
protected PropertyField _unifiedSpringField;
protected Label _springXLabel;
protected PropertyField _springXField;
protected Label _springYLabel;
protected PropertyField _springYField;
protected Label _springZLabel;
protected PropertyField _springZField;
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
SerializedProperty _separateAxis = property.FindPropertyRelative("SeparateAxis");
SerializedProperty _unifiedSpring = property.FindPropertyRelative("UnifiedSpring");
SerializedProperty _springX = property.FindPropertyRelative("SpringX");
SerializedProperty _springY = property.FindPropertyRelative("SpringY");
SerializedProperty _springZ = property.FindPropertyRelative("SpringZ");
Toggle boolToggle = new Toggle("SeparateAxis") { value = property.FindPropertyRelative("SeparateAxis").boolValue };
boolToggle.RegisterValueChangedCallback(evt =>
{
property.FindPropertyRelative("SeparateAxis").boolValue = evt.newValue;
ToggleFields(evt.newValue);
_separateAxis.serializedObject.ApplyModifiedProperties();
});
root.Add(boolToggle);
_unifiedSpringField = new PropertyField(_unifiedSpring);
_springXLabel = new Label("Spring X");
_springXLabel.style.backgroundColor = new StyleColor(new Color(1f,0,0,0.2f));
_springXLabel.style.marginLeft = -10;
_springXLabel.style.paddingLeft = 14;
_springXLabel.style.paddingBottom = 3;
_springXLabel.style.paddingTop = 3;
_springXField = new PropertyField(_springX);
_springYLabel = new Label("Spring Y");
_springYLabel.style.backgroundColor = new StyleColor(new Color(0,1f,0,0.1f));
_springYLabel.style.marginLeft = -10;
_springYLabel.style.paddingLeft = 14;
_springYLabel.style.paddingBottom = 3;
_springYLabel.style.paddingTop = 3;
_springYField = new PropertyField(_springY);
_springZLabel = new Label("Spring Z");
_springZLabel.style.backgroundColor = new StyleColor(new Color(0,0.4f,0.9f,0.2f));
_springZLabel.style.marginLeft = -10;
_springZLabel.style.paddingLeft = 14;
_springZLabel.style.paddingBottom = 3;
_springZLabel.style.paddingTop = 3;
_springZField = new PropertyField(_springZ);
root.Add(_unifiedSpringField);
root.Add(_springXLabel);
root.Add(_springXField);
root.Add(_springYLabel);
root.Add(_springYField);
root.Add(_springZLabel);
root.Add(_springZField);
ToggleFields(boolToggle.value);
return root;
}
private void ToggleFields(bool show)
{
_unifiedSpringField.style.display = show ? DisplayStyle.None : DisplayStyle.Flex;
_springXLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springXField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springYLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springYField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springZLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springZField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0a4e11f66ff9ee844abeabf0af54b970
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/Editor/Springs/MMSpringVector3PropertyDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,110 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMSpringVector4))]
class MMSpringVector4PropertyDrawer : PropertyDrawer
{
protected float _lastTarget;
protected float _max;
protected PropertyField _unifiedSpringField;
protected Label _springXLabel;
protected PropertyField _springXField;
protected Label _springYLabel;
protected PropertyField _springYField;
protected Label _springZLabel;
protected PropertyField _springZField;
protected Label _springWLabel;
protected PropertyField _springWField;
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
SerializedProperty _separateAxis = property.FindPropertyRelative("SeparateAxis");
SerializedProperty _unifiedSpring = property.FindPropertyRelative("UnifiedSpring");
SerializedProperty _springX = property.FindPropertyRelative("SpringX");
SerializedProperty _springY = property.FindPropertyRelative("SpringY");
SerializedProperty _springZ = property.FindPropertyRelative("SpringZ");
SerializedProperty _springW = property.FindPropertyRelative("SpringW");
Toggle boolToggle = new Toggle("SeparateAxis") { value = property.FindPropertyRelative("SeparateAxis").boolValue };
boolToggle.RegisterValueChangedCallback(evt =>
{
property.FindPropertyRelative("SeparateAxis").boolValue = evt.newValue;
ToggleFields(evt.newValue);
_separateAxis.serializedObject.ApplyModifiedProperties();
});
root.Add(boolToggle);
_unifiedSpringField = new PropertyField(_unifiedSpring);
_springXLabel = new Label("Spring X");
_springXLabel.style.backgroundColor = new StyleColor(new Color(1f,0,0,0.2f));
_springXLabel.style.marginLeft = -10;
_springXLabel.style.paddingLeft = 14;
_springXLabel.style.paddingBottom = 3;
_springXLabel.style.paddingTop = 3;
_springXField = new PropertyField(_springX);
_springYLabel = new Label("Spring Y");
_springYLabel.style.backgroundColor = new StyleColor(new Color(0,1f,0,0.1f));
_springYLabel.style.marginLeft = -10;
_springYLabel.style.paddingLeft = 14;
_springYLabel.style.paddingBottom = 3;
_springYLabel.style.paddingTop = 3;
_springYField = new PropertyField(_springY);
_springZLabel = new Label("Spring Z");
_springZLabel.style.backgroundColor = new StyleColor(new Color(0,0.4f,0.9f,0.2f));
_springZLabel.style.marginLeft = -10;
_springZLabel.style.paddingLeft = 14;
_springZLabel.style.paddingBottom = 3;
_springZLabel.style.paddingTop = 3;
_springZField = new PropertyField(_springZ);
_springWLabel = new Label("Spring W");
_springWLabel.style.backgroundColor = new StyleColor(new Color(0.7f,0f,0.7f,0.2f));
_springWLabel.style.marginLeft = -10;
_springWLabel.style.paddingLeft = 14;
_springWLabel.style.paddingBottom = 3;
_springWLabel.style.paddingTop = 3;
_springWField = new PropertyField(_springW);
root.Add(_unifiedSpringField);
root.Add(_springXLabel);
root.Add(_springXField);
root.Add(_springYLabel);
root.Add(_springYField);
root.Add(_springZLabel);
root.Add(_springZField);
root.Add(_springWLabel);
root.Add(_springWField);
ToggleFields(boolToggle.value);
return root;
}
private void ToggleFields(bool show)
{
_unifiedSpringField.style.display = show ? DisplayStyle.None : DisplayStyle.Flex;
_springXLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springXField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springYLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springYField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springZLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springZField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springWLabel.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
_springWField.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: fbd00ea6a74ff2c4295668162e4661bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/Editor/Springs/MMSpringVector4PropertyDrawer.cs
uploadId: 830868