Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c15bb0862679ae743bdf21a29103355a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,264 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Feedbacks
{
[CustomPropertyDrawer(typeof(MMFEnumConditionAttribute))]
public class MMFEnumConditionAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
MMFEnumConditionAttribute enumConditionAttribute = (MMFEnumConditionAttribute)attribute;
bool enabled = GetConditionAttributeResult(enumConditionAttribute, property);
bool previouslyEnabled = GUI.enabled;
GUI.enabled = enabled;
if (!enumConditionAttribute.Hidden || enabled)
{
EditorGUI.PropertyField(position, property, label, true);
}
GUI.enabled = previouslyEnabled;
}
private bool GetConditionAttributeResult(MMFEnumConditionAttribute enumConditionAttribute, SerializedProperty property)
{
bool enabled = true;
string propertyPath = property.propertyPath;
string conditionPath = propertyPath.Replace(property.name, enumConditionAttribute.ConditionEnum);
SerializedProperty sourcePropertyValue = property.serializedObject.FindProperty(conditionPath);
if ((sourcePropertyValue != null) && (sourcePropertyValue.propertyType == SerializedPropertyType.Enum))
{
int currentEnum = sourcePropertyValue.enumValueIndex;
enabled = enumConditionAttribute.ContainsBitFlag(currentEnum);
}
else
{
Debug.LogWarning("No matching boolean found for ConditionAttribute in object: " + enumConditionAttribute.ConditionEnum);
}
return enabled;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
MMFEnumConditionAttribute enumConditionAttribute = (MMFEnumConditionAttribute)attribute;
bool enabled = GetConditionAttributeResult(enumConditionAttribute, property);
if (!enumConditionAttribute.Hidden || enabled)
{
return EditorGUI.GetPropertyHeight(property, label);
}
else
{
int multiplier = 1; // this multiplier fixes issues in differing property spacing between MMFeedbacks and MMF_Player
if (property.depth > 0)
{
multiplier = property.depth;
}
return -EditorGUIUtility.standardVerticalSpacing * multiplier;
}
}
}
// original implementation by http://www.brechtos.com/hiding-or-disabling-inspector-properties-using-propertydrawers-within-unity-5/
[CustomPropertyDrawer(typeof(MMFConditionAttribute))]
public class MMFConditionAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
MMFConditionAttribute conditionAttribute = (MMFConditionAttribute)attribute;
bool enabled = GetConditionAttributeResult(conditionAttribute, property);
bool previouslyEnabled = GUI.enabled;
GUI.enabled = enabled;
if (!conditionAttribute.Hidden || enabled)
{
EditorGUI.PropertyField(position, property, label, true);
}
GUI.enabled = previouslyEnabled;
}
private bool GetConditionAttributeResult(MMFConditionAttribute condHAtt, SerializedProperty property)
{
bool enabled = true;
string propertyPath = property.propertyPath;
string conditionPath = propertyPath.Replace(property.name, condHAtt.ConditionBoolean);
SerializedProperty sourcePropertyValue = property.serializedObject.FindProperty(conditionPath);
if (sourcePropertyValue != null)
{
enabled = sourcePropertyValue.boolValue;
}
else
{
Debug.LogWarning("No matching boolean found for ConditionAttribute in object: " + condHAtt.ConditionBoolean);
}
return enabled;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
MMFConditionAttribute conditionAttribute = (MMFConditionAttribute)attribute;
bool enabled = GetConditionAttributeResult(conditionAttribute, property);
if (!conditionAttribute.Hidden || enabled)
{
return EditorGUI.GetPropertyHeight(property, label);
}
else
{
int multiplier = 1; // this multiplier fixes issues in differing property spacing between MMFeedbacks and MMF_Player
if (property.depth > 0)
{
multiplier = property.depth;
}
return -EditorGUIUtility.standardVerticalSpacing * multiplier;
}
}
}
[CustomPropertyDrawer(typeof(MMFHiddenAttribute))]
public class MMFHiddenAttributeDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return 0f;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
}
}
[CustomPropertyDrawer(typeof(MMFInformationAttribute))]
/// <summary>
/// This class allows the display of a message box (warning, info, error...) next to a property (before or after)
/// </summary>
public class MMFInformationAttributeDrawer : PropertyDrawer
{
// determines the space after the help box, the space before the text box, and the width of the help box icon
const int spaceBeforeTheTextBox = 5;
const int spaceAfterTheTextBox = 10;
const int iconWidth = 55;
MMFInformationAttribute informationAttribute { get { return ((MMFInformationAttribute)attribute); } }
/// <summary>
/// OnGUI, displays the property and the textbox in the specified order
/// </summary>
/// <param name="rect">Rect.</param>
/// <param name="prop">Property.</param>
/// <param name="label">Label.</param>
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
if (HelpEnabled())
{
EditorStyles.helpBox.richText = true;
Rect helpPosition = rect;
Rect textFieldPosition = rect;
if (!informationAttribute.MessageAfterProperty)
{
// we position the message before the property
helpPosition.height = DetermineTextboxHeight(informationAttribute.Message);
textFieldPosition.y += helpPosition.height + spaceBeforeTheTextBox;
textFieldPosition.height = GetPropertyHeight(prop, label);
}
else
{
// we position the property first, then the message
textFieldPosition.height = GetPropertyHeight(prop, label);
helpPosition.height = DetermineTextboxHeight(informationAttribute.Message);
// we add the complete property height (property + helpbox, as overridden in this very script), and substract both to get just the property
helpPosition.y += GetPropertyHeight(prop, label) - DetermineTextboxHeight(informationAttribute.Message) - spaceAfterTheTextBox;
}
EditorGUI.HelpBox(helpPosition, informationAttribute.Message, informationAttribute.Type);
EditorGUI.PropertyField(textFieldPosition, prop, label, true);
}
else
{
Rect textFieldPosition = rect;
textFieldPosition.height = GetPropertyHeight(prop, label);
EditorGUI.PropertyField(textFieldPosition, prop, label, true);
}
}
/// <summary>
/// Returns the complete height of the whole block (property + help text)
/// </summary>
/// <returns>The block height.</returns>
/// <param name="property">Property.</param>
/// <param name="label">Label.</param>
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
if (HelpEnabled())
{
return EditorGUI.GetPropertyHeight(property) + DetermineTextboxHeight(informationAttribute.Message) + spaceAfterTheTextBox + spaceBeforeTheTextBox;
}
else
{
return EditorGUI.GetPropertyHeight(property);
}
}
/// <summary>
/// Checks the editor prefs to see if help is enabled or not
/// </summary>
/// <returns><c>true</c>, if enabled was helped, <c>false</c> otherwise.</returns>
protected virtual bool HelpEnabled()
{
bool helpEnabled = false;
if (EditorPrefs.HasKey("MMShowHelpInInspectors"))
{
if (EditorPrefs.GetBool("MMShowHelpInInspectors"))
{
helpEnabled = true;
}
}
return helpEnabled;
}
/// <summary>
/// Determines the height of the textbox.
/// </summary>
/// <returns>The textbox height.</returns>
/// <param name="message">Message.</param>
protected virtual float DetermineTextboxHeight(string message)
{
GUIStyle style = new GUIStyle(EditorStyles.helpBox);
style.richText = true;
float newHeight = style.CalcHeight(new GUIContent(message), EditorGUIUtility.currentViewWidth - iconWidth);
return newHeight;
}
}
[CustomPropertyDrawer(typeof(MMFReadOnlyAttribute))]
public class MMFReadOnlyAttributeDrawer : PropertyDrawer
{
// Necessary since some properties tend to collapse smaller than their content
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
// Draw a disabled property field
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false; // Disable fields
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true; // Enable fields
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bb4df52d2a954374b913a14cc5d474d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,444 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
using System.Linq;
using System.Collections.Generic;
namespace MoreMountains.Feedbacks
{
public class MMFInspectorGroupData
{
public bool GroupIsOpen;
public MMFInspectorGroupAttribute GroupAttribute;
public List<SerializedProperty> PropertiesList = new List<SerializedProperty>();
public HashSet<string> GroupHashSet = new HashSet<string>();
public Color GroupColor;
public void ClearGroup()
{
GroupAttribute = null;
GroupHashSet.Clear();
PropertiesList.Clear();
}
}
public class MMF_FeedbackInspector
{
public bool DrawerInitialized;
public List<SerializedProperty> PropertiesList = new List<SerializedProperty>();
public Dictionary<string, MMFInspectorGroupData> GroupData = new Dictionary<string, MMFInspectorGroupData>();
private string[] _mmHiddenPropertiesToHide;
private bool _hasMMHiddenProperties = false;
protected bool _shouldDrawBase = true;
protected SerializedProperty _currentProperty;
protected MMF_Feedback _feedback;
protected bool _expandGroupInspectors;
private const string _channelFieldName = "Channel";
private const string _channelModeFieldName = "ChannelMode";
private const string _channelDefinitionFieldName = "MMChannelDefinition";
public virtual void OnEnable()
{
DrawerInitialized = false;
PropertiesList.Clear();
GroupData.Clear();
MMFHiddenPropertiesAttribute[] hiddenProperties = (MMFHiddenPropertiesAttribute[])_currentProperty.GetType().GetCustomAttributes(typeof(MMFHiddenPropertiesAttribute), false);
if (hiddenProperties != null && hiddenProperties.Length > 0 && hiddenProperties[0].PropertiesNames != null)
{
_mmHiddenPropertiesToHide = hiddenProperties[0].PropertiesNames;
_hasMMHiddenProperties = true;
}
}
public virtual void OnDisable()
{
foreach (KeyValuePair<string, MMFInspectorGroupData> groupData in GroupData)
{
if (groupData.Value != null)
{
EditorPrefs.SetBool(string.Format($"{groupData.Value.GroupAttribute.GroupName}{groupData.Value.PropertiesList[0].name}{_feedback.UniqueID}"), groupData.Value.GroupIsOpen);
groupData.Value.ClearGroup();
}
}
}
protected Dictionary<string,MMFConditionAttribute> _conditionDictionary = new Dictionary<string,MMFConditionAttribute>();
protected Dictionary<string,MMFEnumConditionAttribute> _enumConditionDictionary = new Dictionary<string,MMFEnumConditionAttribute>();
protected MMFConditionAttribute _conditionAttributeStore;
protected MMFEnumConditionAttribute _enumConditionAttributeStore;
public virtual void Initialization(SerializedProperty currentProperty, MMF_Feedback feedback, bool expandGroupInspectors)
{
if (DrawerInitialized)
{
return;
}
_expandGroupInspectors = expandGroupInspectors;
_currentProperty = currentProperty;
_feedback = feedback;
_conditionDictionary.Clear();
_enumConditionDictionary.Clear();
List<FieldInfo> fieldInfoList;
MMFInspectorGroupAttribute previousGroupAttribute = default;
int fieldInfoLength = MMF_FieldInfo.GetFieldInfo(feedback, out fieldInfoList);
for (int i = 0; i < fieldInfoLength; i++)
{
SearchForConditions(fieldInfoList[i]);
MMFInspectorGroupAttribute group = Attribute.GetCustomAttribute(fieldInfoList[i], typeof(MMFInspectorGroupAttribute)) as MMFInspectorGroupAttribute;
MMFInspectorGroupData groupData;
if (group == null)
{
if (previousGroupAttribute != null && previousGroupAttribute.GroupAllFieldsUntilNextGroupAttribute)
{
_shouldDrawBase = false;
if (!GroupData.TryGetValue(previousGroupAttribute.GroupName, out groupData))
{
if (!ShouldSkipGroup(previousGroupAttribute.GroupName))
{
GroupData.Add(previousGroupAttribute.GroupName, new MMFInspectorGroupData
{
GroupAttribute = previousGroupAttribute,
GroupHashSet = new HashSet<string> { fieldInfoList[i].Name },
GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex)
});
}
}
else
{
groupData.GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex);
groupData.GroupHashSet.Add(fieldInfoList[i].Name);
}
}
continue;
}
previousGroupAttribute = group;
if (!GroupData.TryGetValue(group.GroupName, out groupData))
{
bool fallbackOpenState = _expandGroupInspectors;
if (group.ClosedByDefault) { fallbackOpenState = false; }
bool groupIsOpen = EditorPrefs.GetBool(string.Format($"{group.GroupName}{fieldInfoList[i].Name}{feedback.UniqueID}"), fallbackOpenState);
if (!ShouldSkipGroup(previousGroupAttribute.GroupName))
{
GroupData.Add(group.GroupName, new MMFInspectorGroupData
{
GroupAttribute = group,
GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex),
GroupHashSet = new HashSet<string> { fieldInfoList[i].Name }, GroupIsOpen = groupIsOpen
});
}
}
else
{
groupData.GroupHashSet.Add(fieldInfoList[i].Name);
groupData.GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex);
}
}
if (currentProperty.NextVisible(true))
{
do
{
FillPropertiesList(currentProperty);
} while (currentProperty.NextVisible(false));
}
DrawerInitialized = true;
}
protected virtual bool ShouldSkipGroup(string groupName)
{
bool skip = false;
if (groupName == MMF_Feedback._randomnessGroupName && !_feedback.HasRandomness)
{
skip = true;
}
if (groupName == MMF_Feedback._rangeGroupName && !_feedback.HasRange)
{
skip = true;
}
return skip;
}
protected virtual void SearchForConditions(FieldInfo fieldInfo)
{
_conditionAttributeStore = Attribute.GetCustomAttribute(fieldInfo, typeof(MMFConditionAttribute)) as MMFConditionAttribute;
if (_conditionAttributeStore != null)
{
_conditionDictionary.Add(fieldInfo.Name, _conditionAttributeStore);
}
_enumConditionAttributeStore = Attribute.GetCustomAttribute(fieldInfo, typeof(MMFEnumConditionAttribute)) as MMFEnumConditionAttribute;
if (_enumConditionAttributeStore != null)
{
_enumConditionDictionary.Add(fieldInfo.Name, _enumConditionAttributeStore);
}
}
public void FillPropertiesList(SerializedProperty serializedProperty)
{
bool shouldClose = false;
foreach (KeyValuePair<string, MMFInspectorGroupData> pair in GroupData)
{
if (pair.Value.GroupHashSet.Contains(serializedProperty.name))
{
SerializedProperty property = serializedProperty.Copy();
shouldClose = true;
pair.Value.PropertiesList.Add(property);
break;
}
}
if (!shouldClose)
{
SerializedProperty property = serializedProperty.Copy();
PropertiesList.Add(property);
}
}
public void DrawInspector(SerializedProperty currentProperty, MMF_Feedback feedback)
{
Initialization(currentProperty, feedback, _expandGroupInspectors);
if (!DrawBase(currentProperty, feedback))
{
DrawContainer(feedback);
DrawContents(feedback);
}
}
protected virtual bool DrawBase(SerializedProperty currentProperty, MMF_Feedback feedback)
{
if (_shouldDrawBase || !feedback.DrawGroupInspectors)
{
DrawNoGroupInspector(currentProperty, feedback);
return true;
}
else
{
return false;
}
}
protected virtual void DrawContainer(MMF_Feedback feedback)
{
if (PropertiesList.Count == 0)
{
return;
}
foreach (KeyValuePair<string, MMFInspectorGroupData> pair in GroupData)
{
DrawVerticalLayout(() => DrawGroup(pair.Value, feedback), MMF_FeedbackInspectorStyle.ContainerStyle);
EditorGUI.indentLevel = 0;
}
}
protected virtual void DrawContents(MMF_Feedback feedback)
{
if (PropertiesList.Count == 0)
{
return;
}
EditorGUILayout.Space();
for (int i = 1; i < PropertiesList.Count; i++)
{
if (_hasMMHiddenProperties && (!_mmHiddenPropertiesToHide.Contains(PropertiesList[i].name)))
{
if (!DrawCustomInspectors(PropertiesList[i], feedback))
{
EditorGUILayout.PropertyField(PropertiesList[i], true);
}
}
}
}
protected Rect _leftBorderRect = new Rect();
protected Rect _setupRect = new Rect();
protected Rect _verticalGroup = new Rect();
protected Rect _widthRect = new Rect();
protected GUIContent _groupTitle = new GUIContent();
protected virtual void DrawGroup(MMFInspectorGroupData groupData, MMF_Feedback feedback)
{
_verticalGroup = EditorGUILayout.BeginVertical();
// we draw a colored line on the left
_leftBorderRect.x = _verticalGroup.xMin + 5;
_leftBorderRect.y = _verticalGroup.yMin - 0;
_leftBorderRect.width = 3f;
_leftBorderRect.height = _verticalGroup.height + 0;
_leftBorderRect.xMin = 15f;
_leftBorderRect.xMax = 18f;
EditorGUI.DrawRect(_leftBorderRect, groupData.GroupColor);
if (groupData.GroupAttribute.RequiresSetup && feedback.RequiresSetup)
{
// we draw a warning sign if needed
_widthRect = EditorGUILayout.GetControlRect(false, 0);
float setupRectWidth = 20f;
_setupRect.x = _widthRect.xMax - setupRectWidth;
_setupRect.y = _verticalGroup.yMin;
_setupRect.width = setupRectWidth;
_setupRect.height = 17f;
EditorGUI.LabelField(_setupRect, MMF_PlayerStyling._setupRequiredIcon);
}
groupData.GroupIsOpen = EditorGUILayout.Foldout(groupData.GroupIsOpen, groupData.GroupAttribute.GroupName, true, MMF_FeedbackInspectorStyle.GroupStyle);
if (groupData.GroupIsOpen)
{
EditorGUI.indentLevel = 0;
for (int i = 0; i < groupData.PropertiesList.Count; i++)
{
DrawVerticalLayout(() => DrawChild(i), MMF_FeedbackInspectorStyle.BoxChildStyle);
}
}
EditorGUILayout.EndVertical();
void DrawChild(int i)
{
if (i > groupData.PropertiesList.Count - 1)
{
return;
}
if ((_hasMMHiddenProperties) && (_mmHiddenPropertiesToHide.Contains(groupData.PropertiesList[i].name)))
{
return;
}
if (!feedback.HasChannel
&& (groupData.PropertiesList[i].name == _channelFieldName
|| groupData.PropertiesList[i].name == _channelModeFieldName
|| groupData.PropertiesList[i].name == _channelDefinitionFieldName))
{
return;
}
_groupTitle.text = ObjectNames.NicifyVariableName(groupData.PropertiesList[i].name);
_groupTitle.tooltip = groupData.PropertiesList[i].tooltip;
if (!DrawCustomInspectors(groupData.PropertiesList[i], feedback))
{
EditorGUILayout.PropertyField(groupData.PropertiesList[i], _groupTitle, true);
}
}
}
public static void DrawVerticalLayout(Action action, GUIStyle style)
{
EditorGUILayout.BeginVertical(style);
action();
EditorGUILayout.EndVertical();
}
public void DrawNoGroupInspector(SerializedProperty currentProperty, MMF_Feedback feedback)
{
SerializedProperty endProp = currentProperty.GetEndProperty();
while (currentProperty.NextVisible(true) && !EqualContents(endProp, currentProperty))
{
if (currentProperty.depth <= 2)
{
if (!DrawCustomInspectors(currentProperty, feedback))
{
EditorGUILayout.PropertyField(currentProperty, true);
}
}
}
}
protected GUIContent _tweenCurveGUIContent = new GUIContent("MM Tween Curve");
protected GUIContent _animationCurveGUIContent = new GUIContent("Animation Curve");
protected const string _customInspectorButtonPropertyName = "MMF_Button";
protected const string _customTweenTypePropertyName = "MMTweenType";
protected const string _findPropertyRelativeMMTweenDefinitionType = "MMTweenDefinitionType";
protected const string _mmTweenCurvePropertyName = "MMTweenCurve";
protected const string _curvePropertyName = "Curve";
protected SerializedProperty _mmTweenTypeProperty;
protected MMFConditionAttribute _conditionAttribute;
protected MMFEnumConditionAttribute _enumConditionAttribute;
private bool DrawCustomInspectors(SerializedProperty currentProperty, MMF_Feedback feedback)
{
if (feedback.HasCustomInspectors)
{
switch (currentProperty.type)
{
case _customInspectorButtonPropertyName:
MMF_Button myButton = (MMF_Button)(currentProperty.MMFGetObjectValue());
if (GUILayout.Button(myButton.ButtonText))
{
myButton.TargetMethod();
}
return true;
case _customTweenTypePropertyName:
// if we're displaying a tween type, we need to handle conditions manually
//
_mmTweenTypeProperty = currentProperty.FindPropertyRelative(_findPropertyRelativeMMTweenDefinitionType);
if (_conditionDictionary.TryGetValue(currentProperty.name, out _conditionAttribute))
{
string propertyPath = currentProperty.propertyPath;
string conditionPath = propertyPath.Replace(currentProperty.name, _conditionAttribute.ConditionBoolean);
SerializedProperty sourcePropertyValue = currentProperty.serializedObject.FindProperty(conditionPath);
if (!sourcePropertyValue.boolValue)
{
return true;
}
}
if (_enumConditionDictionary.TryGetValue(currentProperty.name, out _enumConditionAttribute))
{
string propertyPath = currentProperty.propertyPath;
string conditionPath = propertyPath.Replace(currentProperty.name, _enumConditionAttribute.ConditionEnum);
SerializedProperty sourcePropertyValue = currentProperty.serializedObject.FindProperty(conditionPath);
if ((sourcePropertyValue != null) && (sourcePropertyValue.propertyType == SerializedPropertyType.Enum))
{
int currentEnum = sourcePropertyValue.enumValueIndex;
if (!_enumConditionAttribute.ContainsBitFlag(currentEnum))
{
return true;
}
}
}
EditorGUILayout.PropertyField(_mmTweenTypeProperty, new GUIContent(currentProperty.displayName));
if (_mmTweenTypeProperty.enumValueIndex == 0)
{
EditorGUILayout.PropertyField(currentProperty.FindPropertyRelative(_mmTweenCurvePropertyName), _tweenCurveGUIContent);
}
if (_mmTweenTypeProperty.enumValueIndex == 1)
{
EditorGUILayout.PropertyField(currentProperty.FindPropertyRelative(_curvePropertyName), _animationCurveGUIContent);
}
return true;
}
}
return false;
}
private bool EqualContents(SerializedProperty a, SerializedProperty b)
{
return SerializedProperty.EqualContents(a, b);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a25970639430d894ab27292af3987aa2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
static class MMF_FeedbackInspectorStyle
{
public static GUIStyle ContainerStyle;
public static GUIStyle BoxChildStyle;
public static GUIStyle GroupStyle;
public static GUIStyle TextStyle;
public static bool IsProSkin = EditorGUIUtility.isProSkin;
public static Texture2D GroupClosedTriangle = Resources.Load<Texture2D>("IN foldout focus-6510");
public static Texture2D GroupOpenTriangle = Resources.Load<Texture2D>("IN foldout focus on-5718");
public static Texture2D NoTexture = new Texture2D(0, 0);
static MMF_FeedbackInspectorStyle()
{
// TEXT STYLE --------------------------------------------------------------------------------------------------------------
TextStyle = new GUIStyle(EditorStyles.largeLabel);
TextStyle.richText = true;
TextStyle.contentOffset = new Vector2(0, 25);
//TextStyle.font = Font.CreateDynamicFontFromOSFont(new[] { "Terminus (TTF) for Windows", "Calibri" }, 14);
// GROUP STYLE --------------------------------------------------------------------------------------------------------------
GroupStyle = new GUIStyle(EditorStyles.foldout);
GroupStyle.active.background = GroupClosedTriangle;
GroupStyle.focused.background = GroupClosedTriangle;
GroupStyle.hover.background = GroupClosedTriangle;
GroupStyle.onActive.background = GroupOpenTriangle;
GroupStyle.onFocused.background = GroupOpenTriangle;
GroupStyle.onHover.background = GroupOpenTriangle;
GroupStyle.fontStyle = FontStyle.Bold;
GroupStyle.overflow = new RectOffset(100, 0, 0, 0);
GroupStyle.padding = new RectOffset(20, 0, 0, 0);
// CONTAINER STYLE --------------------------------------------------------------------------------------------------------------
ContainerStyle = new GUIStyle(GUI.skin.box);
ContainerStyle.padding = new RectOffset(20, 0, 0, 0);
// BOX CHILD STYLE --------------------------------------------------------------------------------------------------------------
BoxChildStyle = new GUIStyle(GUI.skin.box);
BoxChildStyle.padding = new RectOffset(0, 0, 0, 0);
BoxChildStyle.margin = new RectOffset(0, 0, 0, 0);
BoxChildStyle.normal.background = NoTexture;
}
static Texture2D MakeTex(int width, int height, Color col)
{
Color[] pix = new Color[width * height];
for (int i = 0; i < pix.Length; ++i)
{
pix[i] = col;
}
Texture2D result = new Texture2D(width, height);
result.SetPixels(pix);
result.Apply();
return result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 678bc44d826a7b54c9edfa8fa70a76ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// An asset to store copy information, as well as global feedback settings.
/// It requires that one (and only one) MMFeedbacksConfiguration asset be created and stored in a Resources folder.
/// That's already done when installing MMFeedbacks.
/// </summary>
[CreateAssetMenu(menuName = "MoreMountains/MMFeedbacks/Configuration", fileName = "MMFeedbacksConfiguration")]
public class MMF_PlayerConfiguration : ScriptableObject
{
private static MMF_PlayerConfiguration _instance;
private static bool _instantiated;
/// <summary>
/// Singleton pattern
/// </summary>
public static MMF_PlayerConfiguration Instance
{
get
{
if (_instantiated)
{
return _instance;
}
string assetName = typeof(MMF_PlayerConfiguration).Name;
MMF_PlayerConfiguration loadedAsset = Resources.Load<MMF_PlayerConfiguration>("MMF_PlayerConfiguration");
_instance = loadedAsset;
_instantiated = true;
return _instance;
}
}
[Header("Help settings")]
/// if this is true, inspector tips will be shown for MMFeedbacks
public bool ShowInspectorTips = true;
/// if this is true, when exiting play mode when KeepPlaymodeChanges is active, it'll turn off automatically, otherwise it'll remain on
public bool AutoDisableKeepPlaymodeChanges = true;
/// if this is true, when exiting play mode when KeepPlaymodeChanges is active, it'll turn off automatically, otherwise it'll remain on
public bool InspectorGroupsExpandedByDefault = true;
private void OnDestroy(){ _instantiated = false; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8bcf466015f0b254893ff0208fccf90f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEditor;
using Object = UnityEngine.Object;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// A helper class to copy and paste feedback properties
/// </summary>
static class MMF_PlayerCopy
{
// Single Copy --------------------------------------------------------------------
static public System.Type Type { get; private set; }
static List<SerializedProperty> Properties = new List<SerializedProperty>();
public static readonly List<MMF_Feedback> CopiedFeedbacks = new List<MMF_Feedback>();
public static List<MMF_Player> ShouldKeepChanges = new List<MMF_Player>();
static string[] IgnoreList = new string[]
{
"m_ObjectHideFlags",
"m_CorrespondingSourceObject",
"m_PrefabInstance",
"m_PrefabAsset",
"m_GameObject",
"m_Enabled",
"m_EditorHideFlags",
"m_Script",
"m_Name",
"m_EditorClassIdentifier"
};
static public bool HasCopy()
{
return CopiedFeedbacks != null && CopiedFeedbacks.Count == 1;
}
static public bool HasMultipleCopies()
{
return CopiedFeedbacks != null && CopiedFeedbacks.Count > 1;
}
static public void Copy(MMF_Feedback feedback)
{
Type feedbackType = feedback.GetType();
MMF_Feedback newFeedback = (MMF_Feedback)Activator.CreateInstance(feedbackType);
EditorUtility.CopySerializedManagedFieldsOnly(feedback, newFeedback);
CopiedFeedbacks.Clear();
CopiedFeedbacks.Add(newFeedback);
}
static public void CopyAll(MMF_Player sourceFeedbacks)
{
CopiedFeedbacks.Clear();
foreach (MMF_Feedback feedback in sourceFeedbacks.FeedbacksList)
{
Type feedbackType = feedback.GetType();
MMF_Feedback newFeedback = (MMF_Feedback)Activator.CreateInstance(feedbackType);
EditorUtility.CopySerializedManagedFieldsOnly(feedback, newFeedback);
CopiedFeedbacks.Add(newFeedback);
}
}
// Multiple Copy ----------------------------------------------------------
static public void PasteAll(MMF_PlayerEditor targetEditor)
{
foreach (MMF_Feedback feedback in MMF_PlayerCopy.CopiedFeedbacks)
{
targetEditor.TargetMmfPlayer.AddFeedback(feedback);
}
CopiedFeedbacks.Clear();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f7bf459716aa484c8db5d1ef3ef8049
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5677ceae3cf1ede41a9bc25c50471513
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,443 @@
using UnityEngine;
using UnityEditor;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// A class used to regroup most of the styling options for the MMFeedback editors
/// </summary>
public static class MMF_PlayerStyling
{
public static readonly GUIStyle SmallTickbox = new GUIStyle("ShurikenToggle");
static readonly Color _splitterdark = new Color(0.12f, 0.12f, 0.12f, 1.333f);
static readonly Color _splitterlight = new Color(0.6f, 0.6f, 0.6f, 1.333f);
public static Color Splitter { get { return EditorGUIUtility.isProSkin ? _splitterdark : _splitterlight; } }
static readonly Color _headerbackgrounddark = new Color(0.1f, 0.1f, 0.1f, 0.2f);
static readonly Color _headerbackgroundlight = new Color(1f, 1f, 1f, 0.4f);
public static Color HeaderBackground { get { return EditorGUIUtility.isProSkin ? _headerbackgrounddark : _headerbackgroundlight; } }
static readonly Color _reorderdark = new Color(1f, 1f, 1f, 0.2f);
static readonly Color _reorderlight = new Color(0.1f, 0.1f, 0.1f, 0.2f);
public static Color Reorder { get { return EditorGUIUtility.isProSkin ? _reorderdark : _reorderlight; } }
static readonly Color _timingDark = new Color(1f, 1f, 1f, 0.5f);
static readonly Color _timingLight = new Color(0f, 0f, 0f, 0.5f);
static readonly Color _targetLabelColor = new Color(1f, 1f, 1f, 0.4f);
static readonly Texture2D _paneoptionsicondark;
static readonly Texture2D _paneoptionsiconlight;
private static Rect _splitterRect;
public static Texture2D PaneOptionsIcon { get { return EditorGUIUtility.isProSkin ? _paneoptionsicondark : _paneoptionsiconlight; } }
static MMF_PlayerStyling()
{
_paneoptionsicondark = (Texture2D)EditorGUIUtility.Load("Builtin Skins/DarkSkin/Images/pane options.png");
_paneoptionsiconlight = (Texture2D)EditorGUIUtility.Load("Builtin Skins/LightSkin/Images/pane options.png");
}
private static GUIStyle _timingStyle = new GUIStyle();
private static Rect _backgroundRect;
private static Rect _progressRect;
private static Rect _timingRect;
private static Rect _reorderRect;
private static Rect _labelRect;
private static Rect _foldoutRect;
private static Rect _toggleRect;
private static Rect _directionRect;
private static Rect _setupRect;
private static Texture2D _menuIcon;
private static Rect _menuRect;
private static Rect _workRect;
private static Rect _colorRect;
private static Rect _genericMenuRect;
private static Color _headerBackgroundColor;
private static Color _barColor;
private static GUIContent _directionUpIcon;
private static GUIStyle _targetLabelStyle;
private static GUIContent _directionDownIcon;
public static GUIContent _setupRequiredIcon;
private static GenericMenu _genericMenu;
public static void CacheStyling()
{
_menuIcon = PaneOptionsIcon;
_menuRect = new Rect();
_colorRect = new Rect();
_directionRect = new Rect();
_setupRect = new Rect();
_timingRect = new Rect();
_directionUpIcon = new GUIContent(Resources.Load("FeelArrowUp") as Texture);
_directionDownIcon = new GUIContent(Resources.Load("FeelArrowDown") as Texture);
_setupRequiredIcon = new GUIContent(Resources.Load("FeelSetupRequired") as Texture);
_genericMenu = new GenericMenu();
_targetLabelStyle = new GUIStyle(GUI.skin.label);
_targetLabelStyle.alignment = TextAnchor.MiddleRight;
_targetLabelStyle.normal.textColor = _targetLabelColor;
}
/// <summary>
/// Simply drow a splitter line and a title bellow
/// </summary>
static public void DrawSection(string title)
{
EditorGUILayout.Space();
DrawSplitter();
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
}
/// <summary>
/// Draw a separator line
/// </summary>
static public void DrawSplitter()
{
// Helper to draw a separator line
_splitterRect = GUILayoutUtility.GetRect(1f, 1f);
_splitterRect.xMin = 0f;
_splitterRect.width += 4f;
if (Event.current.type != EventType.Repaint)
{
return;
}
EditorGUI.DrawRect(_splitterRect, Splitter);
}
/// <summary>
/// Draw a header similar to the one used for the post-process stack
/// </summary>
static public Rect DrawSimpleHeader(ref bool expanded, ref bool activeField, string title)
{
var e = Event.current;
// Initialize Rects
_backgroundRect = GUILayoutUtility.GetRect(1f, 17f);
_reorderRect = _backgroundRect;
_reorderRect.xMin -= 8f;
_reorderRect.y += 5f;
_reorderRect.width = 9f;
_reorderRect.height = 9f;
_labelRect = _backgroundRect;
_labelRect.xMin += 32f;
_labelRect.xMax -= 20f;
_foldoutRect = _backgroundRect;
_foldoutRect.y += 1f;
_foldoutRect.width = 13f;
_foldoutRect.height = 13f;
_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
EditorGUI.DrawRect(_backgroundRect, HeaderBackground);
// Foldout
expanded = GUI.Toggle(_foldoutRect, expanded, GUIContent.none, EditorStyles.foldout);
// Title
EditorGUI.LabelField(_labelRect, title, EditorStyles.boldLabel);
// Active checkbox
activeField = GUI.Toggle(_toggleRect, activeField, GUIContent.none, SmallTickbox);
// Handle events
if (e.type == EventType.MouseDown && _labelRect.Contains(e.mousePosition) && e.button == 0)
{
expanded = !expanded;
e.Use();
}
return _backgroundRect;
}
/// <summary>
/// Draw a header similar to the one used for the post-process stack
/// </summary>
static public Rect DrawHeader(ref bool expanded, ref bool activeField, string title, Color feedbackColor, System.Action<GenericMenu> fillGenericMenu,
float startedAt, float duration, float totalDuration, MMFeedbackTiming timing, bool pause, bool requiresSetup, string requiredTarget, Color displayColor, MMF_Player host)
{
float thisTime = timing.TimescaleMode == TimescaleModes.Scaled ? Time.time : Time.unscaledTime;
float thisDeltaTime = timing.TimescaleMode == TimescaleModes.Scaled ? Time.deltaTime : Time.unscaledDeltaTime;
if (host.ForceTimescaleMode)
{
thisTime = host.ForcedTimescaleMode == TimescaleModes.Scaled ? Time.time : Time.unscaledTime;
thisDeltaTime = host.ForcedTimescaleMode == TimescaleModes.Scaled ? Time.deltaTime : Time.unscaledDeltaTime;
}
var e = Event.current;
// Initialize Rects
_backgroundRect = GUILayoutUtility.GetRect(1f, 17f);
_progressRect = GUILayoutUtility.GetRect(1f, 2f);
var offset = 4f;
_reorderRect = _backgroundRect;
_reorderRect.xMin -= 8f;
_reorderRect.y += 5f;
_reorderRect.width = 9f;
_reorderRect.height = 9f;
_labelRect = _backgroundRect;
_labelRect.xMin += 32f + offset;
_labelRect.xMax -= 20f;
_foldoutRect = _backgroundRect;
_foldoutRect.y += 1f;
_foldoutRect.xMin += offset;
_foldoutRect.width = 13f;
_foldoutRect.height = 13f;
_toggleRect = _backgroundRect;
_toggleRect.x += 16f;
_toggleRect.xMin += offset;
_toggleRect.y += 2f;
_toggleRect.width = 13f;
_toggleRect.height = 13f;
_timingStyle.normal.textColor = EditorGUIUtility.isProSkin ? _timingDark : _timingLight;
_timingStyle.alignment = TextAnchor.MiddleRight;
_colorRect.x = _labelRect.xMin;
_colorRect.y = _labelRect.yMin;
_colorRect.width = 5f;
_colorRect.height = 17f;
_colorRect.xMin = 0f;
_colorRect.xMax = 5f;
EditorGUI.DrawRect(_colorRect, feedbackColor);
// Background rect should be full-width
_backgroundRect.xMin = 0f;
_backgroundRect.width += 4f;
_progressRect.xMin = 0f;
_progressRect.width += 4f;
_headerBackgroundColor = Color.white;
// Background - if color is white we draw the default color
if (!pause)
{
_headerBackgroundColor = HeaderBackground;
}
else
{
_headerBackgroundColor = feedbackColor;
}
if (displayColor != Color.black)
{
_headerBackgroundColor = displayColor;
}
EditorGUI.DrawRect(_backgroundRect, _headerBackgroundColor);
// Foldout
expanded = GUI.Toggle(_foldoutRect, expanded, GUIContent.none, EditorStyles.foldout);
// Title ----------------------------------------------------------------------------------------------------
using (new EditorGUI.DisabledScope(!activeField))
{
EditorGUI.LabelField(_labelRect, title, EditorStyles.boldLabel);
}
// Direction ----------------------------------------------------------------------------------------------
float directionRectWidth = 70f;
_directionRect.x = _labelRect.xMax - directionRectWidth;
_directionRect.y = _labelRect.yMin;
_directionRect.width = directionRectWidth;
_directionRect.height = 17f;
_directionRect.xMin = _labelRect.xMax - directionRectWidth;
_directionRect.xMax = _labelRect.xMax;
if (timing.MMFeedbacksDirectionCondition == MMFeedbackTiming.MMFeedbacksDirectionConditions.OnlyWhenBackwards)
{
EditorGUI.LabelField(_directionRect, _directionUpIcon);
}
if (timing.MMFeedbacksDirectionCondition == MMFeedbackTiming.MMFeedbacksDirectionConditions.OnlyWhenForwards)
{
EditorGUI.LabelField(_directionRect, _directionDownIcon);
}
if (!host.DisplayFullDurationDetails)
{
if (requiresSetup)
{
float setupRectWidth = 90f;
_setupRect.x = _labelRect.xMax - setupRectWidth;
_setupRect.y = _labelRect.yMin;
_setupRect.width = setupRectWidth;
_setupRect.height = 17f;
_setupRect.xMin = _labelRect.xMax - setupRectWidth;
_setupRect.xMax = _labelRect.xMax;
EditorGUI.LabelField(_setupRect, _setupRequiredIcon);
}
else
{
// otherwise we draw the name of our target
float setupRectWidth = _labelRect.width / 2f;
_setupRect.x = _labelRect.xMax - setupRectWidth - 73f;
_setupRect.y = _labelRect.yMin;
_setupRect.width = setupRectWidth;
_setupRect.height = 17f;
EditorGUI.LabelField(_setupRect, requiredTarget, _targetLabelStyle);
}
}
// Time -----------------------------------------------------------------------------------------------------
string timingInfo = "";
bool displayTotal = false;
if (host.DisplayFullDurationDetails)
{
if (timing.InitialDelay != 0)
{
timingInfo += host.ApplyTimeMultiplier(timing.InitialDelay).ToString() + "s + ";
displayTotal = true;
}
timingInfo += duration.ToString("F2") + "s";
if (timing.NumberOfRepeats != 0)
{
float delayBetweenRepeats = host.ApplyTimeMultiplier(timing.DelayBetweenRepeats);
timingInfo += " + "+ timing.NumberOfRepeats.ToString() + " x ";
timingInfo += host.ApplyTimeMultiplier(timing.DelayBetweenRepeats) + "s";
displayTotal = true;
}
if (displayTotal)
{
timingInfo += " = " + totalDuration.ToString("F2") + "s";
}
}
else
{
timingInfo = totalDuration.ToString("F2") + "s";
}
float timingRectWidth = 150f;
_timingRect.x = _labelRect.xMax - timingRectWidth;
_timingRect.y = _labelRect.yMin;
_timingRect.width = timingRectWidth;
_timingRect.height = 17f;
_timingRect.xMin = _labelRect.xMax - timingRectWidth;
_timingRect.xMax = _labelRect.xMax;
EditorGUI.LabelField(_timingRect, timingInfo, _timingStyle);
// Progress bar
if (totalDuration == 0f)
{
totalDuration = 0.1f;
}
if (startedAt == 0f)
{
startedAt = 0.001f;
}
if (host.IsPlaying && (startedAt > 0f) && (thisTime - startedAt < totalDuration + 0.05f))
{
float fullWidth = _progressRect.width;
if (totalDuration == 0f) { totalDuration = 0.1f; }
float percent = ((thisTime - startedAt) / totalDuration) * 100f;
_progressRect.width = percent * fullWidth / 100f;
_barColor = Color.white;
if (thisTime - startedAt > totalDuration)
{
_barColor = Color.yellow;
}
EditorGUI.DrawRect(_progressRect, _barColor);
}
else
{
EditorGUI.DrawRect(_progressRect, _headerBackgroundColor);
}
// Active checkbox
activeField = GUI.Toggle(_toggleRect, activeField, GUIContent.none, SmallTickbox);
_menuRect.x = _labelRect.xMax + 4f;
_menuRect.y = _labelRect.y + 4f;
_menuRect.width = _menuIcon.width;
_menuRect.height = _menuIcon.height;
// Dropdown menu icon
GUI.DrawTexture(_menuRect, _menuIcon);
for(int i = 0; i < 3; i++)
{
_workRect = _reorderRect;
_workRect.height = 1;
_workRect.y = _reorderRect.y + _reorderRect.height * (i / 3.0f);
EditorGUI.DrawRect(_workRect, Reorder);
}
// Handle events
if (e.type == EventType.MouseDown)
{
if (_menuRect.Contains(e.mousePosition))
{
fillGenericMenu(_genericMenu);
_genericMenuRect.x = _menuRect.x;
_genericMenuRect.y = _menuRect.yMax;
_genericMenuRect.width = 0f;
_genericMenuRect.height = 0f;
_genericMenu.DropDown(_genericMenuRect);
e.Use();
}
}
if (e.type == EventType.MouseDown && _labelRect.Contains(e.mousePosition) && e.button == 0)
{
expanded = !expanded;
e.Use();
}
return _backgroundRect;
}
public static void CreateColorTexture(this Texture2D texture2D, Color32 color)
{
Color32[] colorArray = texture2D.GetPixels32();
for (int i = 0; i < colorArray.Length; ++i)
{
colorArray[i] = color;
}
texture2D.SetPixels32(colorArray);
texture2D.Apply();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8f1df3b488b690940994f84f1bd65166
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,351 @@
using UnityEngine;
using UnityEditor;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// A class used to regroup most of the styling options for the MMFeedback editors
/// </summary>
public static class MMFeedbackStyling
{
public static readonly GUIStyle SmallTickbox = new GUIStyle("ShurikenToggle");
static readonly Color _splitterdark = new Color(0.12f, 0.12f, 0.12f, 1.333f);
static readonly Color _splitterlight = new Color(0.6f, 0.6f, 0.6f, 1.333f);
public static Color Splitter { get { return EditorGUIUtility.isProSkin ? _splitterdark : _splitterlight; } }
static readonly Color _headerbackgrounddark = new Color(0.1f, 0.1f, 0.1f, 0.2f);
static readonly Color _headerbackgroundlight = new Color(1f, 1f, 1f, 0.4f);
public static Color HeaderBackground { get { return EditorGUIUtility.isProSkin ? _headerbackgrounddark : _headerbackgroundlight; } }
static readonly Color _reorderdark = new Color(1f, 1f, 1f, 0.2f);
static readonly Color _reorderlight = new Color(0.1f, 0.1f, 0.1f, 0.2f);
public static Color Reorder { get { return EditorGUIUtility.isProSkin ? _reorderdark : _reorderlight; } }
static readonly Color _timingDark = new Color(1f, 1f, 1f, 0.5f);
static readonly Color _timingLight = new Color(0f, 0f, 0f, 0.5f);
static readonly Texture2D _paneoptionsicondark;
static readonly Texture2D _paneoptionsiconlight;
public static Texture2D PaneOptionsIcon { get { return EditorGUIUtility.isProSkin ? _paneoptionsicondark : _paneoptionsiconlight; } }
static MMFeedbackStyling()
{
_paneoptionsicondark = (Texture2D)EditorGUIUtility.Load("Builtin Skins/DarkSkin/Images/pane options.png");
_paneoptionsiconlight = (Texture2D)EditorGUIUtility.Load("Builtin Skins/LightSkin/Images/pane options.png");
}
private static GUIStyle _timingStyle = new GUIStyle();
/// <summary>
/// Simply drow a splitter line and a title bellow
/// </summary>
static public void DrawSection(string title)
{
EditorGUILayout.Space();
DrawSplitter();
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
}
/// <summary>
/// Draw a separator line
/// </summary>
static public void DrawSplitter()
{
// Helper to draw a separator line
var rect = GUILayoutUtility.GetRect(1f, 1f);
rect.xMin = 0f;
rect.width += 4f;
if (Event.current.type != EventType.Repaint)
return;
EditorGUI.DrawRect(rect, Splitter);
}
/// <summary>
/// Draw a header similar to the one used for the post-process stack
/// </summary>
static public Rect DrawSimpleHeader(ref bool expanded, ref bool activeField, string title)
{
var e = Event.current;
// Initialize Rects
var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);
var reorderRect = backgroundRect;
reorderRect.xMin -= 8f;
reorderRect.y += 5f;
reorderRect.width = 9f;
reorderRect.height = 9f;
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 = 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, HeaderBackground);
// Foldout
expanded = GUI.Toggle(foldoutRect, expanded, GUIContent.none, EditorStyles.foldout);
// Title
EditorGUI.LabelField(labelRect, title, EditorStyles.boldLabel);
// Active checkbox
activeField = GUI.Toggle(toggleRect, activeField, GUIContent.none, SmallTickbox);
// Handle events
if (e.type == EventType.MouseDown && labelRect.Contains(e.mousePosition) && e.button == 0)
{
expanded = !expanded;
e.Use();
}
return backgroundRect;
}
/// <summary>
/// Draw a header similar to the one used for the post-process stack
/// </summary>
static public Rect DrawHeader(ref bool expanded, ref bool activeField, string title, Color feedbackColor, System.Action<GenericMenu> fillGenericMenu,
float startedAt, float duration, float totalDuration, MMFeedbackTiming timing, bool pause, MMFeedbacks host)
{
float thisTime = timing.TimescaleMode == TimescaleModes.Scaled ? Time.time : Time.unscaledTime;
float thisDeltaTime = timing.TimescaleMode == TimescaleModes.Scaled ? Time.deltaTime : Time.unscaledDeltaTime;
var e = Event.current;
// Initialize Rects
var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);
var progressRect = GUILayoutUtility.GetRect(1f, 2f);
var offset = 4f;
var reorderRect = backgroundRect;
reorderRect.xMin -= 8f;
reorderRect.y += 5f;
reorderRect.width = 9f;
reorderRect.height = 9f;
var labelRect = backgroundRect;
labelRect.xMin += 32f + offset;
labelRect.xMax -= 20f;
var foldoutRect = backgroundRect;
foldoutRect.y += 1f;
foldoutRect.xMin += offset;
foldoutRect.width = 13f;
foldoutRect.height = 13f;
var toggleRect = backgroundRect;
toggleRect.x += 16f;
toggleRect.xMin += offset;
toggleRect.y += 2f;
toggleRect.width = 13f;
toggleRect.height = 13f;
var menuIcon = PaneOptionsIcon;
var menuRect = new Rect(labelRect.xMax + 4f, labelRect.y + 4f, menuIcon.width, menuIcon.height);
_timingStyle.normal.textColor = EditorGUIUtility.isProSkin ? _timingDark : _timingLight;
_timingStyle.alignment = TextAnchor.MiddleRight;
var colorRect = new Rect(labelRect.xMin, labelRect.yMin, 5f, 17f);
colorRect.xMin = 0f;
colorRect.xMax = 5f;
EditorGUI.DrawRect(colorRect, feedbackColor);
// Background rect should be full-width
backgroundRect.xMin = 0f;
backgroundRect.width += 4f;
progressRect.xMin = 0f;
progressRect.width += 4f;
Color headerBackgroundColor = Color.white;
// Background - if color is white we draw the default color
if (!pause)
{
headerBackgroundColor = HeaderBackground;
}
else
{
headerBackgroundColor = feedbackColor;
}
EditorGUI.DrawRect(backgroundRect, headerBackgroundColor);
// Foldout
expanded = GUI.Toggle(foldoutRect, expanded, GUIContent.none, EditorStyles.foldout);
// Title ----------------------------------------------------------------------------------------------------
using (new EditorGUI.DisabledScope(!activeField))
{
EditorGUI.LabelField(labelRect, title, EditorStyles.boldLabel);
}
// Direction ----------------------------------------------------------------------------------------------
float directionRectWidth = 70f;
var directionRect = new Rect(labelRect.xMax - directionRectWidth, labelRect.yMin, directionRectWidth, 17f);
directionRect.xMin = labelRect.xMax - directionRectWidth;
directionRect.xMax = labelRect.xMax;
if (timing.MMFeedbacksDirectionCondition == MMFeedbackTiming.MMFeedbacksDirectionConditions.OnlyWhenBackwards)
{
Texture arrowUpIcon = Resources.Load("FeelArrowUp") as Texture;
GUIContent directionIcon = new GUIContent(arrowUpIcon);
EditorGUI.LabelField(directionRect, directionIcon);
}
if (timing.MMFeedbacksDirectionCondition == MMFeedbackTiming.MMFeedbacksDirectionConditions.OnlyWhenForwards)
{
Texture arrowDownIcon = Resources.Load("FeelArrowDown") as Texture;
GUIContent directionIcon = new GUIContent(arrowDownIcon);
EditorGUI.LabelField(directionRect, directionIcon);
}
// Time -----------------------------------------------------------------------------------------------------
string timingInfo = "";
bool displayTotal = false;
if (host.DisplayFullDurationDetails)
{
if (timing.InitialDelay != 0)
{
timingInfo += host.ApplyTimeMultiplier(timing.InitialDelay).ToString() + "s + ";
displayTotal = true;
}
timingInfo += duration.ToString("F2") + "s";
if (timing.NumberOfRepeats != 0)
{
float delayBetweenRepeats = host.ApplyTimeMultiplier(timing.DelayBetweenRepeats);
timingInfo += " + "+ timing.NumberOfRepeats.ToString() + " x ";
if (timing.DelayBetweenRepeats > 0)
{
timingInfo += "(";
}
timingInfo += duration + "s";
if (timing.DelayBetweenRepeats > 0)
{
timingInfo += " + " + host.ApplyTimeMultiplier(timing.DelayBetweenRepeats) + "s )";
}
displayTotal = true;
}
if (displayTotal)
{
timingInfo += " = " + totalDuration.ToString("F2") + "s";
}
}
else
{
timingInfo = totalDuration.ToString("F2") + "s";
}
//"[ 2s + 3 x (4s + 1s) ]"
float timingRectWidth = 150f;
var timingRect = new Rect(labelRect.xMax - timingRectWidth, labelRect.yMin, timingRectWidth, 17f);
timingRect.xMin = labelRect.xMax - timingRectWidth;
timingRect.xMax = labelRect.xMax;
EditorGUI.LabelField(timingRect, timingInfo, _timingStyle);
// Progress bar
if (totalDuration == 0f)
{
totalDuration = 0.1f;
}
if (startedAt == 0f)
{
startedAt = 0.001f;
}
if ((startedAt > 0f) && (thisTime - startedAt < totalDuration + 0.05f))
{
float fullWidth = progressRect.width;
if (totalDuration == 0f) { totalDuration = 0.1f; }
float percent = ((thisTime - startedAt) / totalDuration) * 100f;
progressRect.width = percent * fullWidth / 100f;
Color barColor = Color.white;
if (thisTime - startedAt > totalDuration)
{
barColor = Color.yellow;
}
EditorGUI.DrawRect(progressRect, barColor);
}
else
{
EditorGUI.DrawRect(progressRect, headerBackgroundColor);
}
// Active checkbox
activeField = GUI.Toggle(toggleRect, activeField, GUIContent.none, SmallTickbox);
// Dropdown menu icon
GUI.DrawTexture(menuRect, menuIcon);
for(int i = 0; i < 3; i++)
{
Rect r = reorderRect;
r.height = 1;
r.y = reorderRect.y + reorderRect.height * (i / 3.0f);
EditorGUI.DrawRect(r, Reorder);
}
// Handle events
if (e.type == EventType.MouseDown)
{
if (menuRect.Contains(e.mousePosition))
{
var menu = new GenericMenu();
fillGenericMenu(menu);
menu.DropDown(new Rect(new Vector2(menuRect.x, menuRect.yMax), Vector2.zero));
e.Use();
}
}
if (e.type == EventType.MouseDown && labelRect.Contains(e.mousePosition) && e.button == 0)
{
expanded = !expanded;
e.Use();
}
return backgroundRect;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74bba79889819c645bedf0dcd6d6cfa3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,396 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// Color helpers
/// </summary>
public static class MMFeedbacksColors
{
// via https://gist.github.com/LotteMakesStuff/f7ce43f11e545a151b95b5e87f76304c
// NOTE: The follwing color names come from the CSS3 specification, Section 4.3 Extended Color Keywords
// http://www.w3.org/TR/css3-color/#svg-color
public static readonly Color AliceBlue = new Color32(240, 248, 255, 255);
public static readonly Color AntiqueWhite = new Color32(250, 235, 215, 255);
public static readonly Color Aqua = new Color32(0, 255, 255, 255);
public static readonly Color Aquamarine = new Color32(127, 255, 212, 255);
public static readonly Color Azure = new Color32(240, 255, 255, 255);
public static readonly Color Beige = new Color32(245, 245, 220, 255);
public static readonly Color Bisque = new Color32(255, 228, 196, 255);
public static readonly Color Black = new Color32(0, 0, 0, 255);
public static readonly Color BlanchedAlmond = new Color32(255, 235, 205, 255);
public static readonly Color Blue = new Color32(0, 0, 255, 255);
public static readonly Color BlueViolet = new Color32(138, 43, 226, 255);
public static readonly Color Brown = new Color32(165, 42, 42, 255);
public static readonly Color Burlywood = new Color32(222, 184, 135, 255);
public static readonly Color CadetBlue = new Color32(95, 158, 160, 255);
public static readonly Color Chartreuse = new Color32(127, 255, 0, 255);
public static readonly Color Chocolate = new Color32(210, 105, 30, 255);
public static readonly Color Coral = new Color32(255, 127, 80, 255);
public static readonly Color CornflowerBlue = new Color32(100, 149, 237, 255);
public static readonly Color Cornsilk = new Color32(255, 248, 220, 255);
public static readonly Color Crimson = new Color32(220, 20, 60, 255);
public static readonly Color Cyan = new Color32(0, 255, 255, 255);
public static readonly Color DarkBlue = new Color32(0, 0, 139, 255);
public static readonly Color DarkCyan = new Color32(0, 139, 139, 255);
public static readonly Color DarkGoldenrod = new Color32(184, 134, 11, 255);
public static readonly Color DarkGray = new Color32(169, 169, 169, 255);
public static readonly Color DarkGreen = new Color32(0, 100, 0, 255);
public static readonly Color DarkKhaki = new Color32(189, 183, 107, 255);
public static readonly Color DarkMagenta = new Color32(139, 0, 139, 255);
public static readonly Color DarkOliveGreen = new Color32(85, 107, 47, 255);
public static readonly Color DarkOrange = new Color32(255, 140, 0, 255);
public static readonly Color DarkOrchid = new Color32(153, 50, 204, 255);
public static readonly Color DarkRed = new Color32(139, 0, 0, 255);
public static readonly Color DarkSalmon = new Color32(233, 150, 122, 255);
public static readonly Color DarkSeaGreen = new Color32(143, 188, 143, 255);
public static readonly Color DarkSlateBlue = new Color32(72, 61, 139, 255);
public static readonly Color DarkSlateGray = new Color32(47, 79, 79, 255);
public static readonly Color DarkTurquoise = new Color32(0, 206, 209, 255);
public static readonly Color DarkViolet = new Color32(148, 0, 211, 255);
public static readonly Color DeepPink = new Color32(255, 20, 147, 255);
public static readonly Color DeepSkyBlue = new Color32(0, 191, 255, 255);
public static readonly Color DimGray = new Color32(105, 105, 105, 255);
public static readonly Color DodgerBlue = new Color32(30, 144, 255, 255);
public static readonly Color FireBrick = new Color32(178, 34, 34, 255);
public static readonly Color FloralWhite = new Color32(255, 250, 240, 255);
public static readonly Color ForestGreen = new Color32(34, 139, 34, 255);
public static readonly Color Fuchsia = new Color32(255, 0, 255, 255);
public static readonly Color Gainsboro = new Color32(220, 220, 220, 255);
public static readonly Color GhostWhite = new Color32(248, 248, 255, 255);
public static readonly Color Gold = new Color32(255, 215, 0, 255);
public static readonly Color Goldenrod = new Color32(218, 165, 32, 255);
public static readonly Color Gray = new Color32(128, 128, 128, 255);
public static readonly Color Green = new Color32(0, 128, 0, 255);
public static readonly Color GreenYellow = new Color32(173, 255, 47, 255);
public static readonly Color Honeydew = new Color32(240, 255, 240, 255);
public static readonly Color HotPink = new Color32(255, 105, 180, 255);
public static readonly Color IndianRed = new Color32(205, 92, 92, 255);
public static readonly Color Indigo = new Color32(75, 0, 130, 255);
public static readonly Color Ivory = new Color32(255, 255, 240, 255);
public static readonly Color Khaki = new Color32(240, 230, 140, 255);
public static readonly Color Lavender = new Color32(230, 230, 250, 255);
public static readonly Color Lavenderblush = new Color32(255, 240, 245, 255);
public static readonly Color LawnGreen = new Color32(124, 252, 0, 255);
public static readonly Color LemonChiffon = new Color32(255, 250, 205, 255);
public static readonly Color LightBlue = new Color32(173, 216, 230, 255);
public static readonly Color LightCoral = new Color32(240, 128, 128, 255);
public static readonly Color LightCyan = new Color32(224, 255, 255, 255);
public static readonly Color LightGoldenodYellow = new Color32(250, 250, 210, 255);
public static readonly Color LightGray = new Color32(211, 211, 211, 255);
public static readonly Color LightGreen = new Color32(144, 238, 144, 255);
public static readonly Color LightPink = new Color32(255, 182, 193, 255);
public static readonly Color LightSalmon = new Color32(255, 160, 122, 255);
public static readonly Color LightSeaGreen = new Color32(32, 178, 170, 255);
public static readonly Color LightSkyBlue = new Color32(135, 206, 250, 255);
public static readonly Color LightSlateGray = new Color32(119, 136, 153, 255);
public static readonly Color LightSteelBlue = new Color32(176, 196, 222, 255);
public static readonly Color LightYellow = new Color32(255, 255, 224, 255);
public static readonly Color Lime = new Color32(0, 255, 0, 255);
public static readonly Color LimeGreen = new Color32(50, 205, 50, 255);
public static readonly Color Linen = new Color32(250, 240, 230, 255);
public static readonly Color Magenta = new Color32(255, 0, 255, 255);
public static readonly Color Maroon = new Color32(128, 0, 0, 255);
public static readonly Color MediumAquamarine = new Color32(102, 205, 170, 255);
public static readonly Color MediumBlue = new Color32(0, 0, 205, 255);
public static readonly Color MediumOrchid = new Color32(186, 85, 211, 255);
public static readonly Color MediumPurple = new Color32(147, 112, 219, 255);
public static readonly Color MediumSeaGreen = new Color32(60, 179, 113, 255);
public static readonly Color MediumSlateBlue = new Color32(123, 104, 238, 255);
public static readonly Color MediumSpringGreen = new Color32(0, 250, 154, 255);
public static readonly Color MediumTurquoise = new Color32(72, 209, 204, 255);
public static readonly Color MediumVioletRed = new Color32(199, 21, 133, 255);
public static readonly Color MidnightBlue = new Color32(25, 25, 112, 255);
public static readonly Color Mintcream = new Color32(245, 255, 250, 255);
public static readonly Color MistyRose = new Color32(255, 228, 225, 255);
public static readonly Color Moccasin = new Color32(255, 228, 181, 255);
public static readonly Color NavajoWhite = new Color32(255, 222, 173, 255);
public static readonly Color Navy = new Color32(0, 0, 128, 255);
public static readonly Color OldLace = new Color32(253, 245, 230, 255);
public static readonly Color Olive = new Color32(128, 128, 0, 255);
public static readonly Color Olivedrab = new Color32(107, 142, 35, 255);
public static readonly Color Orange = new Color32(255, 165, 0, 255);
public static readonly Color Orangered = new Color32(255, 69, 0, 255);
public static readonly Color Orchid = new Color32(218, 112, 214, 255);
public static readonly Color PaleGoldenrod = new Color32(238, 232, 170, 255);
public static readonly Color PaleGreen = new Color32(152, 251, 152, 255);
public static readonly Color PaleTurquoise = new Color32(175, 238, 238, 255);
public static readonly Color PaleVioletred = new Color32(219, 112, 147, 255);
public static readonly Color PapayaWhip = new Color32(255, 239, 213, 255);
public static readonly Color PeachPuff = new Color32(255, 218, 185, 255);
public static readonly Color Peru = new Color32(205, 133, 63, 255);
public static readonly Color Pink = new Color32(255, 192, 203, 255);
public static readonly Color Plum = new Color32(221, 160, 221, 255);
public static readonly Color PowderBlue = new Color32(176, 224, 230, 255);
public static readonly Color Purple = new Color32(128, 0, 128, 255);
public static readonly Color Red = new Color32(255, 0, 0, 255);
public static readonly Color RosyBrown = new Color32(188, 143, 143, 255);
public static readonly Color RoyalBlue = new Color32(65, 105, 225, 255);
public static readonly Color SaddleBrown = new Color32(139, 69, 19, 255);
public static readonly Color Salmon = new Color32(250, 128, 114, 255);
public static readonly Color SandyBrown = new Color32(244, 164, 96, 255);
public static readonly Color SeaGreen = new Color32(46, 139, 87, 255);
public static readonly Color Seashell = new Color32(255, 245, 238, 255);
public static readonly Color Sienna = new Color32(160, 82, 45, 255);
public static readonly Color Silver = new Color32(192, 192, 192, 255);
public static readonly Color SkyBlue = new Color32(135, 206, 235, 255);
public static readonly Color SlateBlue = new Color32(106, 90, 205, 255);
public static readonly Color SlateGray = new Color32(112, 128, 144, 255);
public static readonly Color Snow = new Color32(255, 250, 250, 255);
public static readonly Color SpringGreen = new Color32(0, 255, 127, 255);
public static readonly Color SteelBlue = new Color32(70, 130, 180, 255);
public static readonly Color Tan = new Color32(210, 180, 140, 255);
public static readonly Color Teal = new Color32(0, 128, 128, 255);
public static readonly Color Thistle = new Color32(216, 191, 216, 255);
public static readonly Color Tomato = new Color32(255, 99, 71, 255);
public static readonly Color Turquoise = new Color32(64, 224, 208, 255);
public static readonly Color Violet = new Color32(238, 130, 238, 255);
public static readonly Color Wheat = new Color32(245, 222, 179, 255);
public static readonly Color White = new Color32(255, 255, 255, 255);
public static readonly Color WhiteSmoke = new Color32(245, 245, 245, 255);
public static readonly Color Yellow = new Color32(255, 255, 0, 255);
public static readonly Color YellowGreen = new Color32(154, 205, 50, 255);
public static readonly Color ReunoYellow = new Color32(255, 196, 0, 255);
public static readonly Color BestRed = new Color32(255, 24, 0, 255);
public static Dictionary<int, Color> ColorDictionary;
public static Color RandomColor()
{
int random = Random.Range(0, 140);
return GetColorAt(random);
}
public static Color GetColorAt(int index)
{
if (ColorDictionary == null)
{
InitializeDictionary();
}
if (index < ColorDictionary.Count)
{
return ColorDictionary[index];
}
else
{
return Color.white;
}
}
public static void InitializeDictionary()
{
ColorDictionary = new Dictionary<int, Color>
{
{ 0, AliceBlue },
{ 1, AntiqueWhite },
{ 2, Aqua },
{ 3, Aquamarine },
{ 4, Azure },
{ 5, Beige },
{ 6, Bisque },
{ 7, Black },
{ 8, BlanchedAlmond },
{ 9, Blue },
{ 10, BlueViolet },
{ 11, Brown },
{ 12, Burlywood },
{ 13, CadetBlue },
{ 14, Chartreuse },
{ 15, Chocolate },
{ 16, Coral },
{ 17, CornflowerBlue },
{ 18, Cornsilk },
{ 19, Crimson },
{ 20, Cyan },
{ 21, DarkBlue },
{ 22, DarkCyan },
{ 23, DarkGoldenrod },
{ 24, DarkGray },
{ 25, DarkGreen },
{ 26, DarkKhaki },
{ 27, DarkMagenta },
{ 28, DarkOliveGreen },
{ 29, DarkOrange },
{ 30, DarkOrchid },
{ 31, DarkRed },
{ 32, DarkSalmon },
{ 33, DarkSeaGreen },
{ 34, DarkSlateBlue },
{ 35, DarkSlateGray },
{ 36, DarkTurquoise },
{ 37, DarkViolet },
{ 38, DeepPink },
{ 39, DeepSkyBlue },
{ 40, DimGray },
{ 41, DodgerBlue },
{ 42, FireBrick },
{ 43, FloralWhite },
{ 44, ForestGreen },
{ 45, Fuchsia },
{ 46, Gainsboro },
{ 47, GhostWhite },
{ 48, Gold },
{ 49, Goldenrod },
{ 50, Gray },
{ 51, Green },
{ 52, GreenYellow },
{ 53, Honeydew },
{ 54, HotPink },
{ 55, IndianRed },
{ 56, Indigo },
{ 57, Ivory },
{ 58, Khaki },
{ 59, Lavender },
{ 60, Lavenderblush },
{ 61, LawnGreen },
{ 62, LemonChiffon },
{ 63, LightBlue },
{ 64, LightCoral },
{ 65, LightCyan },
{ 66, LightGoldenodYellow },
{ 67, LightGray },
{ 68, LightGreen },
{ 69, LightPink },
{ 70, LightSalmon },
{ 71, LightSeaGreen },
{ 72, LightSkyBlue },
{ 73, LightSlateGray },
{ 74, LightSteelBlue },
{ 75, LightYellow },
{ 76, Lime },
{ 77, LimeGreen },
{ 78, Linen },
{ 79, Magenta },
{ 80, Maroon },
{ 81, MediumAquamarine },
{ 82, MediumBlue },
{ 83, MediumOrchid },
{ 84, MediumPurple },
{ 85, MediumSeaGreen },
{ 86, MediumSlateBlue },
{ 87, MediumSpringGreen },
{ 88, MediumTurquoise },
{ 89, MediumVioletRed },
{ 90, MidnightBlue },
{ 91, Mintcream },
{ 92, MistyRose },
{ 93, Moccasin },
{ 94, NavajoWhite },
{ 95, Navy },
{ 96, OldLace },
{ 97, Olive },
{ 98, Olivedrab },
{ 99, Orange },
{ 100, Orangered },
{ 101, Orchid },
{ 102, PaleGoldenrod },
{ 103, PaleGreen },
{ 104, PaleTurquoise },
{ 105, PaleVioletred },
{ 106, PapayaWhip },
{ 107, PeachPuff },
{ 108, Peru },
{ 109, Pink },
{ 110, Plum },
{ 111, PowderBlue },
{ 112, Purple },
{ 113, Red },
{ 114, RosyBrown },
{ 115, RoyalBlue },
{ 116, SaddleBrown },
{ 117, Salmon },
{ 118, SandyBrown },
{ 119, SeaGreen },
{ 120, Seashell },
{ 121, Sienna },
{ 122, Silver },
{ 123, SkyBlue },
{ 124, SlateBlue },
{ 125, SlateGray },
{ 126, Snow },
{ 127, SpringGreen },
{ 128, SteelBlue },
{ 129, Tan },
{ 130, Teal },
{ 131, Thistle },
{ 132, Tomato },
{ 133, Turquoise },
{ 134, Violet },
{ 135, Wheat },
{ 136, White },
{ 137, WhiteSmoke },
{ 138, Yellow },
{ 139, YellowGreen },
{ 140, ReunoYellow },
{ 141, BestRed }
};
}
/// <summary>
/// Returns a random color between the two min/max specified
/// </summary>
/// <param name="color"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns></returns>
public static Color MMRandomColor(this Color color, Color min, Color max)
{
Color c = new Color()
{
r = UnityEngine.Random.Range(min.r, max.r),
g = UnityEngine.Random.Range(min.g, max.g),
b = UnityEngine.Random.Range(min.b, max.b),
a = UnityEngine.Random.Range(min.a, max.a)
};
return c;
}
/// <summary>
/// Tint : Uses HSV color conversions, keeps the original values, multiplies alpha
/// Multiply : The whole color, including alpha, is multiplied over the original
/// Replace : completely replaces the original with the target color
/// ReplaceKeepAlpha : color is replaced but the original alpha channel is ignored
/// Add : target color gets added (including its alpha)
/// </summary>
public enum ColoringMode { Tint, Multiply, Replace, ReplaceKeepAlpha, Add }
public static Color MMColorize(this Color originalColor, Color targetColor, ColoringMode coloringMode, float lerpAmount = 1.0f)
{
Color resultColor = Color.white;
switch (coloringMode)
{
case ColoringMode.Tint:
{
float s_h, s_s, s_v, t_h, t_s, t_v;
Color.RGBToHSV(originalColor, out s_h, out s_s, out s_v);
Color.RGBToHSV(targetColor, out t_h, out t_s, out t_v);
resultColor = Color.HSVToRGB(t_h, t_s, s_v * t_v);
resultColor.a = originalColor.a * targetColor.a;
}
break;
case ColoringMode.Multiply:
resultColor = originalColor * targetColor;
break;
case ColoringMode.Replace:
resultColor = targetColor;
break;
case ColoringMode.ReplaceKeepAlpha:
resultColor = targetColor;
resultColor.a = originalColor.a;
break;
case ColoringMode.Add:
resultColor = originalColor + targetColor;
break;
default:
break;
}
return Color.Lerp(originalColor, resultColor, lerpAmount);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 822282e53ae1ea84d9795a45c89280db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// An asset to store copy information, as well as global feedback settings.
/// It requires that one (and only one) MMFeedbacksConfiguration asset be created and stored in a Resources folder.
/// That's already done when installing MMFeedbacks.
/// </summary>
[CreateAssetMenu(menuName = "MoreMountains/MMFeedbacks/Configuration", fileName = "MMFeedbacksConfiguration")]
public class MMFeedbacksConfiguration : ScriptableObject
{
private static MMFeedbacksConfiguration _instance;
private static bool _instantiated;
/// <summary>
/// Singleton pattern
/// </summary>
public static MMFeedbacksConfiguration Instance
{
get
{
if (_instantiated)
{
return _instance;
}
string assetName = typeof(MMFeedbacksConfiguration).Name;
MMFeedbacksConfiguration loadedAsset = Resources.Load<MMFeedbacksConfiguration>("MMFeedbacksConfiguration");
_instantiated = true;
_instance = loadedAsset;
return _instance;
}
}
[Header("Debug")]
/// storage for copy/paste
public MMFeedbacks _mmFeedbacks;
[Header("Help settings")]
/// if this is true, inspector tips will be shown for MMFeedbacks
public bool ShowInspectorTips = true;
private void OnDestroy(){ _instantiated = false; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00bf1cad26d9e9342b90f463840caf08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 64a86544d830f6144b6588a93f78e3d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e028a42d652a2e449be3c8795c6b39e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dcef6f636a0aab845a6c8d9b97bb4b51
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 378d85c023238454db159ae565d259dd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6b2481f480a67bd4dac8e31521065205
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.PackageManager.Requests;
using UnityEditor.PackageManager;
using UnityEngine;
using System.Threading.Tasks;
using System.Linq;
using System.Text;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This class is used to automatically install optional dependencies used in MMFeedbacks
/// </summary>
public static class FeedbackListOutputer
{
/// <summary>
/// Outputs a list of all MMFeedbacks to the console (there's only one target user for this and it's me hello!)
/// </summary>
[MenuItem("Tools/More Mountains/MMFeedbacks/Output MMFeedbacks list", false, 704)]
public static void OutputFeedbacksList()
{
// Retrieve available feedbacks
List<System.Type> types = (from domainAssembly in System.AppDomain.CurrentDomain.GetAssemblies()
from assemblyType in domainAssembly.GetTypes()
where assemblyType.IsSubclassOf(typeof(MMFeedback))
select assemblyType).ToList();
List<string> typeNames = new List<string>();
string previousType = "";
for (int i = 0; i < types.Count; i++)
{
MMFeedbacksEditor.FeedbackTypePair newType = new MMFeedbacksEditor.FeedbackTypePair();
newType.FeedbackType = types[i];
newType.FeedbackName = FeedbackPathAttribute.GetFeedbackDefaultPath(types[i]);
if (newType.FeedbackName == "MMFeedbackBase")
{
continue;
}
string newEntry = FeedbackPathAttribute.GetFeedbackDefaultPath(newType.FeedbackType);
typeNames.Add(newEntry);
}
typeNames.Sort();
StringBuilder builder = new StringBuilder();
int counter = 1;
foreach (string typeName in typeNames)
{
if (typeName == null)
{
continue;
}
string[] splitArray = typeName.Split(char.Parse("/"));
if ((previousType != splitArray[0]) && (counter > 1))
{
builder.Append("\n");
}
builder.Append("- [ ] ");
builder.Append(counter.ToString("000"));
builder.Append(" - ");
builder.Append(typeName);
builder.Append("\n");
previousType = splitArray[0];
counter++;
}
Debug.Log(builder.ToString());
}
/// <summary>
/// Outputs a list of all MMFeedbacks to the console (there's only one target user for this and it's me hello!)
/// </summary>
[MenuItem("Tools/More Mountains/MMFeedbacks/Output MMF_Feedbacks list", false, 705)]
public static void OutputIFeedbacksList()
{
// Retrieve available feedbacks
List<System.Type> types = (from domainAssembly in System.AppDomain.CurrentDomain.GetAssemblies()
from assemblyType in domainAssembly.GetTypes()
where assemblyType.IsSubclassOf(typeof(MMF_Feedback))
select assemblyType).ToList();
List<string> typeNames = new List<string>();
string previousType = "";
for (int i = 0; i < types.Count; i++)
{
MMFeedbacksEditor.FeedbackTypePair newType = new MMFeedbacksEditor.FeedbackTypePair();
newType.FeedbackType = types[i];
newType.FeedbackName = FeedbackPathAttribute.GetFeedbackDefaultPath(types[i]);
if (newType.FeedbackName == "MMF_FeedbackBase")
{
continue;
}
string newEntry = FeedbackPathAttribute.GetFeedbackDefaultPath(newType.FeedbackType);
typeNames.Add(newEntry);
}
typeNames.Sort();
StringBuilder builder = new StringBuilder();
int counter = 1;
foreach (string typeName in typeNames)
{
if (typeName == null)
{
continue;
}
string[] splitArray = typeName.Split(char.Parse("/"));
if ((previousType != splitArray[0]) && (counter > 1))
{
builder.Append("\n");
}
builder.Append("- [ ] ");
builder.Append(counter.ToString("000"));
builder.Append(" - ");
builder.Append(typeName);
builder.Append("\n");
previousType = splitArray[0];
counter++;
}
Debug.Log(builder.ToString());
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f832a347ffbe22e478be454dc5dc3cff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 04eddc1d6a8109645a0d9160d1c807dc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a4beaab234dd88a499a16fd7a67bb948
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
{
"name": "MoreMountains.Feedbacks.Editor",
"references": [
"GUID:8087d854c1f812e4b9a74437dfc524e0"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 06b83c50b355d0f4d81f9571afaf8805
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 198046438e4ccfa469931b781c7c8685
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,159 @@
fileFormatVersion: 2
guid: a29898adbcfeacb438ad390d9e925afe
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,159 @@
fileFormatVersion: 2
guid: 87529e0fd28c3774fa086315a42b1860
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 1d575a145584c7549994d8a51c689ef8
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8bcf466015f0b254893ff0208fccf90f, type: 3}
m_Name: MMF_PlayerConfiguration
m_EditorClassIdentifier:
ShowInspectorTips: 1
AutoDisableKeepPlaymodeChanges: 1
InspectorGroupsExpandedByDefault: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c14ab46a507c8324c8b54e6a3fdc2b0e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 00bf1cad26d9e9342b90f463840caf08, type: 3}
m_Name: MMFeedbacksConfiguration
m_EditorClassIdentifier:
_mmFeedbacks: {fileID: 0}
ShowInspectorTips: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 59a4add72d602ce4a9693b14a97d2a83
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4afdef3fd4947674681b935fb47100f1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,189 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// Custom editor for sequence recorder
/// </summary>
[CustomEditor(typeof(MMInputSequenceRecorder), true)]
[CanEditMultipleObjects]
public class MMInputSequenceRecorderEditor : Editor
{
protected SerializedProperty _Recording;
protected float _inspectorWidth;
protected int _externalMargin = 10;
protected Rect _rect;
protected Color _recordingColor = Color.red;
protected Color _recordingTextColor = Color.white;
protected Vector2 _boxPosition;
protected Vector2 _boxSize;
protected GUIStyle _recordingStyle;
protected MMInputSequenceRecorder _targetRecorder;
protected Event _currentEvent;
/// <summary>
/// Forces constant inspector repaints
/// </summary>
/// <returns></returns>
public override bool RequiresConstantRepaint()
{
return true;
}
/// <summary>
/// On enable we initialize our styles and listen for input in editor mode
/// </summary>
protected virtual void OnEnable()
{
_Recording = serializedObject.FindProperty("Recording");
_recordingStyle = new GUIStyle();
_recordingStyle.normal.textColor = Color.white;
_recordingStyle.fontSize = 30;
_recordingStyle.alignment = TextAnchor.MiddleCenter;
_targetRecorder = (MMInputSequenceRecorder)target;
System.Reflection.FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null);
value += EditorGlobalKeyPress;
info.SetValue(null, value);
}
/// <summary>
/// Looks for input
/// </summary>
protected virtual void EditorGlobalKeyPress()
{
if (Application.isPlaying)
{
return;
}
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
_currentEvent = Event.current;
if (_currentEvent == null)
{
return;
}
DetectStartAndEnd();
EditorDetectRecording();
}
/// <summary>
/// Detects presses on the start or end keys
/// </summary>
protected virtual void DetectStartAndEnd()
{
if (_currentEvent.isKey)
{
if (!_targetRecorder.Recording)
{
if ((_currentEvent.keyCode == _targetRecorder.StartRecordingHotkey) && (_currentEvent.type == EventType.KeyDown))
{
_targetRecorder.StartRecording();
}
}
else
{
if ((_currentEvent.keyCode == _targetRecorder.StopRecordingHotkey) && (_currentEvent.type == EventType.KeyDown))
{
_targetRecorder.StopRecording();
}
}
}
}
/// <summary>
/// Looks for key presses on sequence key bindings
/// </summary>
protected virtual void EditorDetectRecording()
{
if (_targetRecorder.Recording && (_targetRecorder.SequenceScriptableObject != null))
{
if (_currentEvent.isKey)
{
foreach (MMSequenceTrack track in _targetRecorder.SequenceScriptableObject.SequenceTracks)
{
if (_currentEvent.keyCode == (track.Key))
{
if (track.State == MMSequenceTrackStates.Up)
{
track.State = MMSequenceTrackStates.Idle;
}
if (_currentEvent.type == EventType.KeyDown)
{
if (track.State != MMSequenceTrackStates.Down)
{
// key is down for the first time
_targetRecorder.AddNoteToTrack(track);
}
track.State = MMSequenceTrackStates.Down;
}
if (_currentEvent.type == EventType.KeyUp)
{
// key is up
track.State = MMSequenceTrackStates.Up;
}
}
}
}
}
}
/// <summary>
/// Draws the custom inspector
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
Undo.RecordObject(target, "Modified Sequence Recorder");
_inspectorWidth = EditorGUIUtility.currentViewWidth - 24;
// display recording label
if (_Recording.boolValue)
{
GUILayout.Box("", GUILayout.Width(_inspectorWidth - _externalMargin), GUILayout.Height(50));
_boxPosition = GUILayoutUtility.GetLastRect().position;
_boxSize = GUILayoutUtility.GetLastRect().size;
_rect.x = _boxPosition.x;
_rect.y = _boxPosition.y;
_rect.width = _boxSize.x;
_rect.height = _boxSize.y;
EditorGUI.DrawRect(_rect, _recordingColor);
EditorGUI.LabelField(_rect, "RECORDING", _recordingStyle);
}
DrawDefaultInspector();
// separator
EditorGUILayout.Space();
EditorGUILayout.LabelField("Controls", EditorStyles.boldLabel);
if (!_Recording.boolValue)
{
// display start recording button
if (GUILayout.Button("Start Recording"))
{
_targetRecorder.StartRecording();
}
}
else
{
// display stop recording button
if (GUILayout.Button("Stop Recording"))
{
_targetRecorder.StopRecording();
}
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 356e077c6b0c8614fa08b93f8099bedf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,418 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// Custom editor for MMSequencer, handles recalibration and sequencer display
/// </summary>
[CustomEditor(typeof(MMSequencer), true)]
[CanEditMultipleObjects]
public class MMSequencerEditor : Editor
{
protected MMSequencer _targetSequencer;
protected float _inspectorWidth;
protected GUIStyle _buttonStyle;
protected GUIStyle _trackControlStyle;
protected GUIStyle _indexStyle;
protected Texture2D _buttonBackground;
protected Texture2D _dotBackground;
protected Color _buttonColor;
protected Color _trackControlColor;
protected Color _emptyButtonColor = new Color(0,0,0,0.5f);
protected Color _empty4ButtonColor = new Color(0, 0, 0, 0.75f);
protected const float _buttonWidth = 24;
protected const float _trackControlWidth = 11;
protected const float _distanceBetweenButtons = 6f;
protected int _boxesPerLine;
protected Color _originalBackgroundColor;
protected Color _controlColor;
protected List<float> _trackControlLastUseTimestamps;
/// <summary>
/// We want constant repaint on this inspector
/// </summary>
/// <returns></returns>
public override bool RequiresConstantRepaint()
{
return true;
}
/// <summary>
/// On enable we grab our textures and initialize our styles
/// </summary>
protected virtual void OnEnable()
{
_targetSequencer = (MMSequencer)target;
_buttonBackground = Resources.Load("SequencerButtonBackground") as Texture2D;
_dotBackground = Resources.Load("SequencerDotBackground") as Texture2D;
_originalBackgroundColor = GUI.backgroundColor;
_buttonStyle = new GUIStyle();
_buttonStyle.normal.background = _buttonBackground;
_buttonStyle.fixedWidth = _buttonWidth;
_buttonStyle.fixedHeight = _buttonWidth;
_trackControlStyle = new GUIStyle();
_trackControlStyle.normal.background = _dotBackground;
_trackControlStyle.normal.textColor = (Application.isPlaying) ? Color.black : Color.white;
_trackControlStyle.fixedWidth = _trackControlWidth;
_trackControlStyle.fixedHeight = _trackControlWidth;
_trackControlStyle.margin = new RectOffset(0, 0, 1, 0);
_trackControlStyle.alignment = TextAnchor.MiddleCenter;
_trackControlStyle.fontSize = 10;
_indexStyle = new GUIStyle();
_indexStyle.normal.background = _dotBackground;
_indexStyle.normal.textColor = Color.white;
_indexStyle.alignment = TextAnchor.MiddleCenter;
_indexStyle.fixedWidth = _trackControlWidth * 1.5f;
_indexStyle.fixedHeight = _trackControlWidth * 1.5f;
FillControlList();
}
protected virtual void FillControlList()
{
// fill the control timer list
if (_targetSequencer.Sequence != null)
{
_trackControlLastUseTimestamps = new List<float>();
foreach (MMSequenceTrack track in _targetSequencer.Sequence.SequenceTracks)
{
_trackControlLastUseTimestamps.Add(0f);
}
}
}
/// <summary>
/// Draws the default inspector and the sequencer
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
Undo.RecordObject(target, "Modified Sequence Recorder");
DrawDefaultInspector();
if (_targetSequencer.Sequence == null)
{
_targetSequencer.LastSequence = null;
return;
}
// gets the width and computes how many boxes we can fit per line
_inspectorWidth = EditorGUIUtility.currentViewWidth - 24;
_boxesPerLine = (int)Mathf.Round(
(_inspectorWidth - ((_targetSequencer.Sequence.SequenceTracks.Count) * _distanceBetweenButtons) - _trackControlWidth - _distanceBetweenButtons)
/ (_buttonWidth + _distanceBetweenButtons)
) + 1;
LookForChanges();
// separator
EditorGUILayout.Space();
EditorGUILayout.LabelField("Sequencer", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Destroy and rebuild sequence", EditorStyles.miniButtonLeft))
{
_targetSequencer.Sequence.QuantizedSequence = null;
_targetSequencer.LastTracksCount = -1;
_targetSequencer.ApplySequencerLengthToSequence();
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
if (GUILayout.Button("Clear Sequence", EditorStyles.miniButtonMid))
{
_targetSequencer.ClearSequence();
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
if (GUILayout.Button("[ - ] Length - 1", EditorStyles.miniButtonMid))
{
_targetSequencer.DecrementLength();
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
if (GUILayout.Button("[ + ] Length + 1", EditorStyles.miniButtonRight))
{
_targetSequencer.IncrementLength();
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
EditorGUILayout.Space();
DrawSequenceIndexes();
for (int i = 0; i < _targetSequencer.Sequence.SequenceTracks.Count; i++)
{
DrawTrack(i);
}
DrawControlButtons();
serializedObject.ApplyModifiedProperties();
}
/// <summary>
/// Whenever we detect a change in the settings we recalibrate our sequence accordingly
/// </summary>
protected virtual void LookForChanges()
{
if (_targetSequencer.LastSequence != _targetSequencer.Sequence)
{
FillControlList();
if (_targetSequencer.Sequence.QuantizedSequence.Count > 0)
{
if (_targetSequencer.Sequence.QuantizedSequence[0].Line.Count != _targetSequencer.SequencerLength)
{
_targetSequencer.SequencerLength = _targetSequencer.Sequence.QuantizedSequence[0].Line.Count;
_targetSequencer.LastSequencerLength = _targetSequencer.SequencerLength;
_targetSequencer.LastSequence = _targetSequencer.Sequence;
_targetSequencer.LastTracksCount = _targetSequencer.Sequence.SequenceTracks.Count;
}
}
else
{
_targetSequencer.ApplySequencerLengthToSequence();
_targetSequencer.LastSequence = _targetSequencer.Sequence;
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
}
if (_targetSequencer.LastSequence == _targetSequencer.Sequence)
{
if (_targetSequencer.LastTracksCount != _targetSequencer.Sequence.SequenceTracks.Count)
{
FillControlList();
_targetSequencer.ApplySequencerLengthToSequence();
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
if (_targetSequencer.LastBPM != _targetSequencer.BPM)
{
_targetSequencer.UpdateTimestampsToMatchNewBPM();
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
}
_targetSequencer.EditorMaintenance();
}
/// <summary>
/// Draws control buttons
/// </summary>
protected virtual void DrawControlButtons()
{
if (!Application.isPlaying)
{
return;
}
GUI.backgroundColor = _originalBackgroundColor;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Controls", EditorStyles.boldLabel);
if (_targetSequencer.Playing)
{
if (GUILayout.Button("Stop Playing"))
{
_targetSequencer.StopSequence();
}
}
else
{
if (GUILayout.Button("Start Playing"))
{
_targetSequencer.PlaySequence();
}
}
if (GUILayout.Button("Play Next Beat"))
{
_targetSequencer.PlayBeat();
}
}
/// <summary>
/// Draws an index for each sequence item
/// </summary>
protected virtual void DrawSequenceIndexes()
{
GUILayout.BeginHorizontal();
GUI.backgroundColor = _emptyButtonColor;
GUILayout.Label("", GUILayout.Width(_trackControlWidth + _distanceBetweenButtons), GUILayout.Height(_trackControlWidth));
string label = "";
for (int i = 0; i < _targetSequencer.SequencerLength; i++)
{
label = i < 10 ? " " + i.ToString() : i.ToString();
_trackControlStyle.fontStyle = (i % 4 == 0) ? FontStyle.Bold : FontStyle.Normal;
//GUILayout.Label(label, _indexStyle, GUILayout.Width(_buttonWidth + _distanceBetweenButtons), GUILayout.Height(_trackControlWidth));
if (GUILayout.Button(label, _indexStyle, GUILayout.Width(_buttonWidth + _distanceBetweenButtons), GUILayout.Height(_trackControlWidth)))
{
_targetSequencer.ToggleStep(i);
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
}
GUI.backgroundColor = _originalBackgroundColor;
GUILayout.EndHorizontal();
GUILayout.Space(_distanceBetweenButtons * 1.5f);
}
/// <summary>
/// Draws a line of the sequencer
/// </summary>
/// <param name="trackIndex"></param>
protected virtual void DrawTrack(int trackIndex)
{
int counter = 0;
if (_targetSequencer.Sequence.QuantizedSequence == null)
{
return;
}
if (_targetSequencer.Sequence.QuantizedSequence.Count != _targetSequencer.Sequence.SequenceTracks.Count)
{
return;
}
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
// draw active track control
if (_targetSequencer.Sequence.SequenceTracks[trackIndex].Active)
{
_trackControlColor = _targetSequencer.Sequence.SequenceTracks[trackIndex].TrackColor;
}
else
{
_trackControlColor = _emptyButtonColor;
}
GUI.backgroundColor = _trackControlColor;
if (GUILayout.Button("", _trackControlStyle, GUILayout.Width(_trackControlWidth), GUILayout.Height(_trackControlWidth)))
{
if (_targetSequencer.TrackEvents[trackIndex] != null)
{
_targetSequencer.ToggleActive(trackIndex);
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
}
GUILayout.Space(_distanceBetweenButtons / 5);
// draw test track control
_trackControlColor = _targetSequencer.Sequence.SequenceTracks[trackIndex].TrackColor;
_controlColor = Application.isPlaying ? SequencerColor(_trackControlLastUseTimestamps[trackIndex], _trackControlColor) : Color.black;
GUI.backgroundColor = _controlColor;
if (GUILayout.Button(trackIndex.ToString(), _trackControlStyle, GUILayout.Width(_trackControlWidth), GUILayout.Height(_trackControlWidth)))
{
if (_targetSequencer.TrackEvents[trackIndex] != null)
{
_trackControlLastUseTimestamps[trackIndex] = Time.time;
_targetSequencer.PlayTrackEvent(trackIndex);
}
}
GUILayout.EndVertical();
GUILayout.Space(_distanceBetweenButtons);
for (int i = 0; i < _targetSequencer.Sequence.QuantizedSequence[trackIndex].Line.Count; i++)
{
// handle new lines
if (counter > _boxesPerLine )
{
GUILayout.EndHorizontal();
GUILayout.Space(_distanceBetweenButtons);
GUILayout.BeginHorizontal();
counter = 0;
}
if (_targetSequencer.Sequence.QuantizedSequence[trackIndex].Line[i].ID != -1)
{
_buttonColor = _targetSequencer.Sequence.SequenceTracks[trackIndex].TrackColor;
}
else
{
if (i % 4 == 0)
{
_buttonColor = _empty4ButtonColor;
}
else
{
_buttonColor = _emptyButtonColor;
}
}
// if the track is inactive, we reduce colors
if (!_targetSequencer.Sequence.SequenceTracks[trackIndex].Active)
{
_buttonColor = _buttonColor / 2f;
}
DrawSequenceButton(trackIndex, i, _buttonColor);
counter++;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(_distanceBetweenButtons);
}
/// <summary>
/// Draws an interactive button for the sequencer
/// </summary>
/// <param name="trackIndex"></param>
/// <param name="sequenceIndex"></param>
/// <param name="buttonColor"></param>
protected virtual void DrawSequenceButton(int trackIndex, int sequenceIndex, Color buttonColor)
{
if (Application.isPlaying && _targetSequencer.PlayedOnce && (_targetSequencer.LastBeatIndex == sequenceIndex))
{
if (_targetSequencer.BeatThisFrame)
{
_buttonColor = Color.white;
}
else
{
_buttonColor = SequencerColor(_targetSequencer.LastBeatTimestamp, buttonColor);
}
}
else
{
_buttonColor = buttonColor;
}
GUI.backgroundColor = _buttonColor;
if (GUILayout.Button("", _buttonStyle, GUILayout.Width(_buttonWidth), GUILayout.Height(_buttonWidth)))
{
bool active = (_targetSequencer.Sequence.QuantizedSequence[trackIndex].Line[sequenceIndex].ID == _targetSequencer.Sequence.SequenceTracks[trackIndex].ID);
_targetSequencer.Sequence.QuantizedSequence[trackIndex].Line[sequenceIndex].ID = active ? -1 : _targetSequencer.Sequence.SequenceTracks[trackIndex].ID;
EditorUtility.SetDirty(_targetSequencer.Sequence);
}
GUILayout.Space(_distanceBetweenButtons);
}
/// <summary>
/// Color interpolation on hits
/// </summary>
/// <param name="lastBeatTimestamp"></param>
/// <param name="buttonColor"></param>
/// <returns></returns>
protected virtual Color SequencerColor(float lastBeatTimestamp, Color buttonColor)
{
float x = (Time.time - lastBeatTimestamp);
float A = 0f;
float B = (60f / _targetSequencer.BPM) / 4f;
float C = 0f;
float D = 1f;
float t = C + (x - A) / (B - A) * (D - C);
return Color.Lerp(Color.white, buttonColor, t);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6f57413f575191641b987d9d04e61e3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45d354ba7398508478aa7bd1ea7fd93d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

View File

@@ -0,0 +1,159 @@
fileFormatVersion: 2
guid: e802b29e86b4ef74abe728250ecaf37c
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 2, y: 2, z: 2, w: 2}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

View File

@@ -0,0 +1,159 @@
fileFormatVersion: 2
guid: 82c9d5c8726c57249b51c39e76eee072
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2578f5ded293ceb49bcce2465e848ec0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,251 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
[CanEditMultipleObjects]
[CustomEditor(typeof(MMWiggle))]
public class MMWiggleEditor : Editor
{
public struct WiggleEditorProperties
{
public SerializedProperty WigglePermitted;
public SerializedProperty WiggleType;
public SerializedProperty UseUnscaledTime;
public SerializedProperty RelativeAmplitude;
public SerializedProperty UniformValues;
public SerializedProperty StartWigglingAutomatically;
public SerializedProperty SmoothPingPong;
public SerializedProperty UseSpeedCurve;
public SerializedProperty SpeedCurve;
public SerializedProperty FrequencyMin;
public SerializedProperty FrequencyMax;
public SerializedProperty AmplitudeMin;
public SerializedProperty AmplitudeMax;
public SerializedProperty PauseMin;
public SerializedProperty PauseMax;
public SerializedProperty NoiseFrequencyMin;
public SerializedProperty NoiseFrequencyMax;
public SerializedProperty NoiseShiftMin;
public SerializedProperty NoiseShiftMax;
public SerializedProperty LimitedTime;
public SerializedProperty LimitedTimeTotal;
public SerializedProperty LimitedTimeLeft;
public SerializedProperty LimitedTimeFalloff;
public SerializedProperty LimitedTimeResetValue;
public SerializedProperty Curve;
public SerializedProperty RemapCurveZeroMin;
public SerializedProperty RemapCurveZeroMax;
public SerializedProperty RemapCurveOneMin;
public SerializedProperty RemapCurveOneMax;
public SerializedProperty RelativeCurveAmplitude;
public SerializedProperty CurvePingPong;
}
protected SerializedProperty _updateMode;
protected SerializedProperty _positionActive;
protected SerializedProperty _rotationActive;
protected SerializedProperty _scaleActive;
protected SerializedProperty _positionProperties;
protected SerializedProperty _rotationProperties;
protected SerializedProperty _scaleProperties;
protected WiggleEditorProperties _positionEditorProperties;
protected WiggleEditorProperties _rotationEditorProperties;
protected WiggleEditorProperties _scaleEditorProperties;
protected SerializedProperty _debugWiggleDuration;
protected MMWiggle _mmWiggle;
public bool StartWigglingAutomatically = true;
protected virtual void OnEnable()
{
_mmWiggle = (MMWiggle)target;
_updateMode = serializedObject.FindProperty("UpdateMode");
_positionProperties = serializedObject.FindProperty("PositionWiggleProperties");
_rotationProperties = serializedObject.FindProperty("RotationWiggleProperties");
_scaleProperties = serializedObject.FindProperty("ScaleWiggleProperties");
_positionActive = serializedObject.FindProperty("PositionActive");
_rotationActive = serializedObject.FindProperty("RotationActive");
_scaleActive = serializedObject.FindProperty("ScaleActive");
_debugWiggleDuration = serializedObject.FindProperty("DebugWiggleDuration");
InitializeProperties(_positionProperties, ref _positionEditorProperties);
InitializeProperties(_rotationProperties, ref _rotationEditorProperties);
InitializeProperties(_scaleProperties, ref _scaleEditorProperties);
}
protected virtual void InitializeProperties(SerializedProperty targetProperty, ref WiggleEditorProperties editorProperties)
{
editorProperties.WigglePermitted = targetProperty.FindPropertyRelative("WigglePermitted");
editorProperties.WiggleType = targetProperty.FindPropertyRelative("WiggleType");
editorProperties.UseUnscaledTime = targetProperty.FindPropertyRelative("UseUnscaledTime");
editorProperties.RelativeAmplitude = targetProperty.FindPropertyRelative("RelativeAmplitude");
editorProperties.UniformValues = targetProperty.FindPropertyRelative("UniformValues");
editorProperties.StartWigglingAutomatically = targetProperty.FindPropertyRelative("StartWigglingAutomatically");
editorProperties.SmoothPingPong = targetProperty.FindPropertyRelative("SmoothPingPong");
editorProperties.UseSpeedCurve = targetProperty.FindPropertyRelative("UseSpeedCurve");
editorProperties.SpeedCurve = targetProperty.FindPropertyRelative("SpeedCurve");
editorProperties.FrequencyMin = targetProperty.FindPropertyRelative("FrequencyMin");
editorProperties.FrequencyMax = targetProperty.FindPropertyRelative("FrequencyMax");
editorProperties.AmplitudeMin = targetProperty.FindPropertyRelative("AmplitudeMin");
editorProperties.AmplitudeMax = targetProperty.FindPropertyRelative("AmplitudeMax");
editorProperties.PauseMin = targetProperty.FindPropertyRelative("PauseMin");
editorProperties.PauseMax = targetProperty.FindPropertyRelative("PauseMax");
editorProperties.NoiseFrequencyMin = targetProperty.FindPropertyRelative("NoiseFrequencyMin");
editorProperties.NoiseFrequencyMax = targetProperty.FindPropertyRelative("NoiseFrequencyMax");
editorProperties.NoiseShiftMin = targetProperty.FindPropertyRelative("NoiseShiftMin");
editorProperties.NoiseShiftMax = targetProperty.FindPropertyRelative("NoiseShiftMax");
editorProperties.LimitedTime = targetProperty.FindPropertyRelative("LimitedTime");
editorProperties.LimitedTimeTotal = targetProperty.FindPropertyRelative("LimitedTimeTotal");
editorProperties.LimitedTimeLeft = targetProperty.FindPropertyRelative("LimitedTimeLeft");
editorProperties.LimitedTimeFalloff = targetProperty.FindPropertyRelative("LimitedTimeFalloff");
editorProperties.LimitedTimeResetValue = targetProperty.FindPropertyRelative("LimitedTimeResetValue");
editorProperties.Curve = targetProperty.FindPropertyRelative("Curve");
editorProperties.RemapCurveZeroMin = targetProperty.FindPropertyRelative("RemapCurveZeroMin");
editorProperties.RemapCurveZeroMax = targetProperty.FindPropertyRelative("RemapCurveZeroMax");
editorProperties.RemapCurveOneMin = targetProperty.FindPropertyRelative("RemapCurveOneMin");
editorProperties.RemapCurveOneMax = targetProperty.FindPropertyRelative("RemapCurveOneMax");
editorProperties.RelativeCurveAmplitude = targetProperty.FindPropertyRelative("RelativeCurveAmplitude");
editorProperties.CurvePingPong = targetProperty.FindPropertyRelative("CurvePingPong");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
Undo.RecordObject(target, "Modified MMWiggle");
EditorGUILayout.Space();
EditorGUILayout.PropertyField(_updateMode);
EditorGUILayout.Space();
MMFeedbackStyling.DrawSplitter();
DrawValueEditor("Position", _positionActive, _positionEditorProperties, _mmWiggle.PositionWiggleProperties.WiggleType);
DrawValueEditor("Rotation", _rotationActive, _rotationEditorProperties, _mmWiggle.RotationWiggleProperties.WiggleType);
DrawValueEditor("Scale", _scaleActive, _scaleEditorProperties, _mmWiggle.ScaleWiggleProperties.WiggleType);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Debug", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_debugWiggleDuration);
EditorGUILayout.BeginHorizontal();
{
if (GUILayout.Button("Wiggle Position", EditorStyles.miniButtonLeft))
{
_mmWiggle.WigglePosition(_debugWiggleDuration.floatValue);
}
if (GUILayout.Button("Wiggle Rotation", EditorStyles.miniButtonMid))
{
_mmWiggle.WiggleRotation(_debugWiggleDuration.floatValue);
}
if (GUILayout.Button("Wiggle Scale", EditorStyles.miniButtonRight))
{
_mmWiggle.WiggleScale(_debugWiggleDuration.floatValue);
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
serializedObject.ApplyModifiedProperties();
}
protected virtual void DrawValueEditor(string title, SerializedProperty propertyActive, WiggleEditorProperties editorProperties, WiggleTypes wiggleType)
{
bool propertyIsExpanded = propertyActive.isExpanded;
bool propertyIsActive = propertyActive.boolValue;
Rect headerRect = MMFeedbackStyling.DrawSimpleHeader(
ref propertyIsExpanded,
ref propertyIsActive,
title);
propertyActive.isExpanded = propertyIsExpanded;
propertyActive.boolValue = propertyIsActive;
if (propertyIsExpanded)
{
EditorGUI.BeginDisabledGroup(!propertyIsActive);
EditorGUILayout.PropertyField(editorProperties.WigglePermitted);
EditorGUILayout.PropertyField(editorProperties.WiggleType);
EditorGUILayout.PropertyField(editorProperties.UseUnscaledTime);
if ((wiggleType == WiggleTypes.PingPong) || (wiggleType == WiggleTypes.Random))
{
if (wiggleType == WiggleTypes.PingPong)
{
EditorGUILayout.PropertyField(editorProperties.SmoothPingPong);
}
EditorGUILayout.PropertyField(editorProperties.UseSpeedCurve);
if (editorProperties.UseSpeedCurve.boolValue)
{
EditorGUILayout.PropertyField(editorProperties.SpeedCurve);
}
EditorGUILayout.PropertyField(editorProperties.AmplitudeMin);
EditorGUILayout.PropertyField(editorProperties.AmplitudeMax);
EditorGUILayout.PropertyField(editorProperties.RelativeAmplitude);
EditorGUILayout.PropertyField(editorProperties.UniformValues);
EditorGUILayout.PropertyField(editorProperties.FrequencyMin);
EditorGUILayout.PropertyField(editorProperties.FrequencyMax);
EditorGUILayout.PropertyField(editorProperties.PauseMin);
EditorGUILayout.PropertyField(editorProperties.PauseMax);
}
if (wiggleType == WiggleTypes.Noise)
{
EditorGUILayout.PropertyField(editorProperties.AmplitudeMin);
EditorGUILayout.PropertyField(editorProperties.AmplitudeMax);
EditorGUILayout.PropertyField(editorProperties.RelativeAmplitude);
EditorGUILayout.PropertyField(editorProperties.UniformValues);
EditorGUILayout.PropertyField(editorProperties.NoiseFrequencyMin);
EditorGUILayout.PropertyField(editorProperties.NoiseFrequencyMax);
EditorGUILayout.PropertyField(editorProperties.NoiseShiftMin);
EditorGUILayout.PropertyField(editorProperties.NoiseShiftMax);
}
if (wiggleType == WiggleTypes.Curve)
{
EditorGUILayout.PropertyField(editorProperties.Curve);
EditorGUILayout.PropertyField(editorProperties.RemapCurveZeroMin);
EditorGUILayout.PropertyField(editorProperties.RemapCurveZeroMax);
EditorGUILayout.PropertyField(editorProperties.RemapCurveOneMin);
EditorGUILayout.PropertyField(editorProperties.RemapCurveOneMax);
EditorGUILayout.PropertyField(editorProperties.RelativeCurveAmplitude);
EditorGUILayout.PropertyField(editorProperties.UniformValues);
EditorGUILayout.PropertyField(editorProperties.CurvePingPong);
EditorGUILayout.PropertyField(editorProperties.FrequencyMin);
EditorGUILayout.PropertyField(editorProperties.FrequencyMax);
}
EditorGUILayout.PropertyField(editorProperties.LimitedTime);
if (editorProperties.LimitedTime.boolValue)
{
EditorGUILayout.PropertyField(editorProperties.LimitedTimeTotal);
EditorGUILayout.PropertyField(editorProperties.LimitedTimeLeft);
EditorGUILayout.PropertyField(editorProperties.LimitedTimeFalloff);
EditorGUILayout.PropertyField(editorProperties.LimitedTimeResetValue);
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.Space();
}
MMFeedbackStyling.DrawSplitter();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0ad790ad6438c39448c9177b592c30fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: