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,29 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
public enum MMBackgroundAttributeColor
{
Red,
Pink,
Orange,
Yellow,
Green,
Blue,
Violet,
White
}
public class MMBackgroundColorAttribute : PropertyAttribute
{
public MMBackgroundAttributeColor Color;
public MMBackgroundColorAttribute(MMBackgroundAttributeColor color = MMBackgroundAttributeColor.Yellow)
{
this.Color = color;
}
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
public class MMColorAttribute : PropertyAttribute
{
public Color color;
public MMColorAttribute(float red = 1, float green = 0, float blue = 0)
{
this.color = new Color(red, green, blue, 1);
}
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
public class MMConditionAttribute : PropertyAttribute
{
public string ConditionBoolean = "";
public bool Hidden = false;
public MMConditionAttribute(string conditionBoolean)
{
this.ConditionBoolean = conditionBoolean;
this.Hidden = false;
}
public MMConditionAttribute(string conditionBoolean, bool hideInInspector)
{
this.ConditionBoolean = conditionBoolean;
this.Hidden = hideInInspector;
}
}
}

View File

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

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// An attribute to add to static methods to they can be called via the MMDebugMenu's command line
/// </summary>
[AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false)]
public class MMDebugLogCommandArgumentCountAttribute : System.Attribute
{
public readonly int ArgumentCount;
public MMDebugLogCommandArgumentCountAttribute(int argumentCount)
{
this.ArgumentCount = argumentCount;
}
}
}

View File

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

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// An attribute to add to static methods to they can be called via the MMDebugMenu's command line
/// </summary>
[AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false)]
public class MMDebugLogCommandAttribute : System.Attribute { }
}

View File

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

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
public class MMDropdownAttribute : PropertyAttribute
{
public readonly object[] DropdownValues;
public MMDropdownAttribute(params object[] dropdownValues)
{
DropdownValues = dropdownValues;
}
}
}

View File

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

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
/// <summary>
/// An attribute to conditionnally hide fields based on the current selection in an enum.
/// Usage : [MMEnumCondition("rotationMode", (int)RotationMode.LookAtTarget, (int)RotationMode.RotateToAngles)]
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
public class MMEnumConditionAttribute : PropertyAttribute
{
public string ConditionEnum = "";
public bool Hidden = false;
BitArray bitArray = new BitArray(32);
public bool ContainsBitFlag(int enumValue)
{
return bitArray.Get(enumValue);
}
public MMEnumConditionAttribute(string conditionBoolean, params int[] enumValues)
{
this.ConditionEnum = conditionBoolean;
this.Hidden = true;
for (int i = 0; i < enumValues.Length; i++)
{
bitArray.Set(enumValues[i], true);
}
}
}
}

View File

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

View File

@@ -0,0 +1,159 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
/// <summary>
/// Add this attribute to a class and its Execution Order will be changed to the value specified in parameters
/// Usage : [ExecutionOrder(66)]
/// </summary>
public class MMExecutionOrderAttribute : Attribute
{
#if UNITY_EDITOR
/// the execution order you want for the class this attribute is applied to
public int ExecutionOrder = 0;
protected static Dictionary<MonoScript, MMExecutionOrderAttribute> _monoScripts;
protected static Type _executionOrderAttributeType;
protected static Assembly _typeAssembly;
protected static Type[] _assemblyTypes;
/// <summary>
/// Attribute method
/// </summary>
/// <param name="newExecutionOrder"></param>
public MMExecutionOrderAttribute(int newExecutionOrder)
{
ExecutionOrder = newExecutionOrder;
}
/// <summary>
/// When Unity loads, modifies the execution orders of monos with an ExecutionOrder attribute, if needed
/// </summary>
[InitializeOnLoadMethod]
protected static void ModifyExecutionOrder()
{
Initialization();
FindExecutionOrderAttributes();
if (ExecutionOrderHasChanged())
{
UpdateExecutionOrders();
}
}
/// <summary>
/// Initialization method
/// </summary>
protected static void Initialization()
{
_monoScripts = new Dictionary<MonoScript, MMExecutionOrderAttribute>();
_executionOrderAttributeType = typeof(MMExecutionOrderAttribute);
_typeAssembly = _executionOrderAttributeType.Assembly;
_assemblyTypes = _typeAssembly.GetTypes();
}
/// <summary>
/// Goes through all assembly types and stores execution order attributes when found
/// </summary>
protected static void FindExecutionOrderAttributes()
{
foreach (Type assemblyType in _assemblyTypes)
{
if (!HasExecutionOrderAttribute(assemblyType))
{
continue;
}
object[] attributes = assemblyType.GetCustomAttributes(_executionOrderAttributeType, false);
MMExecutionOrderAttribute attribute = attributes[0] as MMExecutionOrderAttribute;
string asset = "";
string[] guids = AssetDatabase.FindAssets(assemblyType.Name + " t:script");
if (guids.Length != 0)
{
foreach (string guid in guids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
string filename = Path.GetFileNameWithoutExtension(assetPath);
if (filename == assemblyType.Name)
{
asset = guid;
break;
}
}
}
else
{
Debug.LogError("MMTools' ExecutionOrderAttribute : Can't change "+ assemblyType.Name + "'s execution order");
return;
}
MonoScript monoScript = AssetDatabase.LoadAssetAtPath<MonoScript>(AssetDatabase.GUIDToAssetPath(asset));
_monoScripts.Add(monoScript, attribute);
}
}
/// <summary>
/// Returns true if the class in parameters has the ExecutionOrder attribute, false otherwise
/// </summary>
/// <param name="assemblyType"></param>
/// <returns></returns>
protected static bool HasExecutionOrderAttribute(Type assemblyType)
{
object[] attributes = assemblyType.GetCustomAttributes(_executionOrderAttributeType, false);
return (attributes.Length == 1);
}
/// <summary>
/// Returns true if the execution order has changed since last time
/// </summary>
/// <returns></returns>
protected static bool ExecutionOrderHasChanged()
{
bool executionOrderHasChanged = false;
foreach (KeyValuePair<MonoScript, MMExecutionOrderAttribute> monoScript in _monoScripts)
{
if (monoScript.Key != null)
{
if (MonoImporter.GetExecutionOrder(monoScript.Key) != monoScript.Value.ExecutionOrder)
{
executionOrderHasChanged = true;
break;
}
}
}
return executionOrderHasChanged;
}
/// <summary>
/// Updates the execution orders for all pairs found by FindExecutionOrderAttributes()
/// </summary>
protected static void UpdateExecutionOrders()
{
foreach (KeyValuePair<MonoScript, MMExecutionOrderAttribute> monoScript in _monoScripts)
{
if (monoScript.Key != null)
{
if (MonoImporter.GetExecutionOrder(monoScript.Key) != monoScript.Value.ExecutionOrder)
{
MonoImporter.SetExecutionOrder(monoScript.Key, monoScript.Value.ExecutionOrder);
}
}
}
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
public class MMHiddenAttribute : PropertyAttribute { }
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 171bddfe1b8d24a049ab93c4b4d2323d
timeCreated: 1456675987
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public class MMHiddenPropertiesAttribute : Attribute
{
public string[] PropertiesNames;
public MMHiddenPropertiesAttribute(params string[] propertiesNames)
{
PropertiesNames = propertiesNames;
}
}
}

View File

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

View File

@@ -0,0 +1,37 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
public class MMInformationAttribute : PropertyAttribute
{
public enum InformationType { Error, Info, None, Warning }
#if UNITY_EDITOR
public string Message;
public MessageType Type;
public bool MessageAfterProperty;
public MMInformationAttribute(string message, InformationType type, bool messageAfterProperty)
{
this.Message = message;
if (type==InformationType.Error) { this.Type = UnityEditor.MessageType.Error;}
if (type==InformationType.Info) { this.Type = UnityEditor.MessageType.Info;}
if (type==InformationType.Warning) { this.Type = UnityEditor.MessageType.Warning;}
if (type==InformationType.None) { this.Type = UnityEditor.MessageType.None;}
this.MessageAfterProperty = messageAfterProperty;
}
#else
public MMInformationAttribute(string message, InformationType type, bool messageAfterProperty)
{
}
#endif
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a083e52b3b6964a0d88af5b74900af5e
timeCreated: 1459528299
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Reflection;
namespace MoreMountains.Tools
{
[System.AttributeUsage(System.AttributeTargets.Field)]
public class MMInspectorButtonAttribute : PropertyAttribute
{
public readonly string MethodName;
public MMInspectorButtonAttribute(string MethodName)
{
this.MethodName = MethodName;
}
}
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(MMInspectorButtonAttribute))]
public class InspectorButtonPropertyDrawer : PropertyDrawer
{
private MethodInfo _eventMethodInfo = null;
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
{
MMInspectorButtonAttribute inspectorButtonAttribute = (MMInspectorButtonAttribute)attribute;
float buttonLength = position.width;
Rect buttonRect = new Rect(position.x, position.y, buttonLength, position.height);
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
if (GUI.Button(buttonRect, inspectorButtonAttribute.MethodName))
{
System.Type eventOwnerType = prop.serializedObject.targetObject.GetType();
string eventName = inspectorButtonAttribute.MethodName;
if (_eventMethodInfo == null)
{
_eventMethodInfo = eventOwnerType.GetMethod(eventName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
if (_eventMethodInfo != null)
{
_eventMethodInfo.Invoke(prop.serializedObject.targetObject, null);
}
else
{
Debug.LogWarning(string.Format("InspectorButton: Unable to find method {0} in {1}", eventName, eventOwnerType));
}
}
}
}
#endif
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 325b5ef7494cead4fbd33a7e9c22c44d
timeCreated: 1490625668
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// An attribute used to group inspector fields under common dropdowns
/// Implementation inspired by Rodrigo Prinheiro's work, available at https://github.com/RodrigoPrinheiro/unityFoldoutAttribute
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
public class MMInspectorGroupAttribute : PropertyAttribute
{
public string GroupName;
public bool GroupAllFieldsUntilNextGroupAttribute;
public int GroupColorIndex;
public MMInspectorGroupAttribute(string groupName, bool groupAllFieldsUntilNextGroupAttribute = false, int groupColorIndex = 24)
{
if (groupColorIndex > 139) { groupColorIndex = 139; }
this.GroupName = groupName;
this.GroupAllFieldsUntilNextGroupAttribute = groupAllFieldsUntilNextGroupAttribute;
this.GroupColorIndex = groupColorIndex;
}
}
}

View File

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

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
public class MMMonoBehaviour : MonoBehaviour
{
}
}

View File

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

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
public class MMReadOnlyAttribute : PropertyAttribute { }
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f54d7ad2fa8f4411e8cceb8d27f6e1ae
timeCreated: 1456675993
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
public class MMReadOnlyWhenPlayingAttribute : PropertyAttribute { }
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(MMReadOnlyWhenPlayingAttribute))]
public class ReadOnlyWhenPlayingAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = !Application.isPlaying;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
}
#endif
}

View File

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

View File

@@ -0,0 +1,13 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
[AttributeUsage(AttributeTargets.Class)]
public class MMRequiresConstantRepaintAttribute : Attribute
{
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
public class MMVectorAttribute : PropertyAttribute
{
public readonly string[] Labels;
public MMVectorAttribute(params string[] labels)
{
Labels = labels;
}
}
}

View File

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