Added Feel plugin

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

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// A super simple mono you can add to an object to call its Quit method, which will force the application to quit.
/// </summary>
public class MMApplicationQuit : MonoBehaviour
{
[Header("Debug")]
[MMInspectorButton("Quit")]
public bool QuitButton;
/// <summary>
/// Forces the application to quit
/// </summary>
public virtual void Quit()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5d8e35f0e39f9744095dbb47ae3363a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMApplicationQuit.cs
uploadId: 830868

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to an empty object in your scene and it'll act as a point of control to enable or disable logs and debug draws
/// </summary>
[AddComponentMenu("More Mountains/Tools/Utilities/MM Debug Controller")]
public class MMDebugController : MonoBehaviour
{
/// whether or not debug logs (MMDebug.DebugLogTime, MMDebug.DebugOnScreen) should be displayed
public bool DebugLogsEnabled = true;
/// whether or not debug draws should be executed
public bool DebugDrawEnabled = true;
/// <summary>
/// On Awake we turn our static debug checks on or off
/// </summary>
protected virtual void Awake()
{
MMDebug.SetDebugLogsEnabled(DebugLogsEnabled);
MMDebug.SetDebugDrawEnabled(DebugDrawEnabled);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0fcb0ff7991255940900581218e0053b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMDebugController.cs
uploadId: 830868

View File

@@ -0,0 +1,29 @@
using UnityEngine;
namespace MoreMountains.Tools
{
[System.Serializable]
public class MMLayer
{
[SerializeField]
protected int _layerIndex = 0;
public virtual int LayerIndex
{
get { return _layerIndex; }
}
public virtual void Set(int _layerIndex)
{
if (_layerIndex > 0 && _layerIndex < 32)
{
this._layerIndex = _layerIndex;
}
}
public virtual int Mask
{
get { return 1 << _layerIndex; }
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: adde5948123bd8743a0048c044871b09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMLayer.cs
uploadId: 830868

View File

@@ -0,0 +1,22 @@
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// A class used to open a URL specified in its inspector
/// </summary>
[AddComponentMenu("More Mountains/Tools/Utilities/MM Open URL")]
public class MMOpenURL : MonoBehaviour
{
/// the URL to open when calling OpenURL()
public string DestinationURL;
/// <summary>
/// Opens the URL specified in the DestinationURL field
/// </summary>
public virtual void OpenURL()
{
Application.OpenURL(DestinationURL);
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: dee3b2b4131e71b4896b58b4361de7ac
timeCreated: 1523905996
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMOpenURL.cs
uploadId: 830868

View File

@@ -0,0 +1,84 @@
using UnityEngine;
using UnityEngine.SceneManagement;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
using UnityEngine.InputSystem;
#endif
namespace MoreMountains.Tools
{
/// <summary>
/// This component lets you restart a scene by pressing a key
/// </summary>
[AddComponentMenu("More Mountains/Tools/Utilities/MM Scene Restarter")]
public class MMSceneRestarter : MonoBehaviour
{
/// the possible restart modes
public enum RestartModes { ActiveScene, SpecificScene }
[Header("Settings")]
/// the selected restart mode, either the currently active scene, or one by name
public RestartModes RestartMode = RestartModes.ActiveScene;
/// the name of the scene to load if we're in specific scene mode
[MMEnumCondition("RestartMode", (int)RestartModes.SpecificScene)]
public string SceneName;
/// the load mode
public LoadSceneMode LoadMode = LoadSceneMode.Single;
[Header("Input")]
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
/// the key to press to restart manually
public Key RestarterKey = Key.Backspace;
#else
/// the key to press to restart manually
public KeyCode RestarterKeyCode = KeyCode.Backspace;
#endif
protected string _newSceneName;
/// <summary>
/// On Update, looks for input
/// </summary>
protected virtual void Update()
{
HandleInput();
}
/// <summary>
/// Looks for a key press of the specified key
/// </summary>
protected virtual void HandleInput()
{
bool keyPressed = false;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
keyPressed = Keyboard.current[RestarterKey].wasPressedThisFrame;
#else
keyPressed = Input.GetKeyDown(RestarterKeyCode);
#endif
if (keyPressed)
{
RestartScene();
}
}
/// <summary>
/// Restarts the scene based on the specified settings
/// </summary>
public virtual void RestartScene()
{
MMDebug.DebugLogInfo("Scene restarted by MMSceneRestarter");
switch (RestartMode)
{
case RestartModes.ActiveScene:
Scene scene = SceneManager.GetActiveScene();
_newSceneName = scene.name;
break;
case RestartModes.SpecificScene:
_newSceneName = SceneName;
break;
}
SceneManager.LoadScene(_newSceneName, LoadMode);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0988d9b4b34ac9c49a36cf9a04cf5776
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMSceneRestarter.cs
uploadId: 830868

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to a gameobject and it'll display its name on the scene view, selected or not.
/// </summary>
[AddComponentMenu("More Mountains/Tools/Icons/MM Scene View Icon")]
public class MMSceneViewIcon : MonoBehaviour
{
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: d0cf5074ca154b84c9792d6d8c1e8ab0
timeCreated: 1523894192
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMSceneViewIcon.cs
uploadId: 830868

View File

@@ -0,0 +1,139 @@
using UnityEngine;
using System.IO;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
using UnityEngine.InputSystem;
#endif
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to an empty game object in your scene and it'll let you take screenshots (meant to be used in Editor)
/// </summary>
[AddComponentMenu("More Mountains/Tools/Utilities/MM Screenshot")]
public class MMScreenshot : MonoBehaviour
{
/// the name of the folder (relative to the project's root) to save screenshots to
public string FolderName = "Screenshots";
/// the method to use to take the screenshot. Screencapture uses the API of the same name, and will let you keep
/// whatever ratio the game view has, RenderTexture renders to a texture of the specified resolution
public enum Methods { ScreenCapture, RenderTexture }
[Header("Screenshot")]
/// the selected method to take a screenshot with.
public Methods Method = Methods.ScreenCapture;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
/// the key to press to restart manually
public Key ScreenshotKey = Key.K;
#else
/// the shortcut to watch for to take screenshots
public KeyCode ScreenshotShortcut = KeyCode.K;
#endif
/// the size by which to multiply the game view when taking the screenshot
[MMEnumCondition("Method", (int)Methods.ScreenCapture)]
public int GameViewSizeMultiplier = 3;
/// the camera to use to take the screenshot with
[MMEnumCondition("Method", (int)Methods.RenderTexture)]
public Camera TargetCamera;
/// the width of the desired screenshot
[MMEnumCondition("Method", (int)Methods.RenderTexture)]
public int ResolutionWidth;
/// the height of the desired screenshot
[MMEnumCondition("Method", (int)Methods.RenderTexture)]
public int ResolutionHeight;
[Header("Controls")]
/// a test button to take screenshots with
[MMInspectorButton("TakeScreenshot")]
public bool TakeScreenshotButton;
/// <summary>
/// At late update, we look for input
/// </summary>
protected virtual void LateUpdate()
{
DetectInput();
}
/// <summary>
/// If the user presses the screenshot button, we take one
/// </summary>
protected virtual void DetectInput()
{
bool keyPressed = false;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
keyPressed = Keyboard.current[ScreenshotKey].wasPressedThisFrame;
#else
keyPressed = Input.GetKeyDown(ScreenshotShortcut);
#endif
if (keyPressed)
{
TakeScreenshot();
}
}
/// <summary>
/// Takes a screenshot using the specified method and outputs a console log
/// </summary>
protected virtual void TakeScreenshot()
{
if (!Directory.Exists(FolderName))
{
Directory.CreateDirectory(FolderName);
}
string savePath = "";
switch (Method)
{
case Methods.ScreenCapture:
savePath = TakeScreenCaptureScreenshot();
break;
case Methods.RenderTexture:
savePath = TakeRenderTextureScreenshot();
break;
}
MMDebug.DebugLogInfo("[MMScreenshot] Screenshot taken and saved at " + savePath);
}
/// <summary>
/// Takes a screenshot using the ScreenCapture API and saves it to file
/// </summary>
/// <returns></returns>
protected virtual string TakeScreenCaptureScreenshot()
{
float width = Screen.width * GameViewSizeMultiplier;
float height = Screen.height * GameViewSizeMultiplier;
string savePath = FolderName+"/screenshot_" + width + "x" + height + "_" + System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".png";
ScreenCapture.CaptureScreenshot(savePath, GameViewSizeMultiplier);
return savePath;
}
/// <summary>
/// Takes a screenshot using a render texture and saves it to file
/// </summary>
/// <returns></returns>
protected virtual string TakeRenderTextureScreenshot()
{
string savePath = FolderName + "/screenshot_" + ResolutionWidth + "x" + ResolutionHeight + "_" + System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".png";
RenderTexture renderTexture = new RenderTexture(ResolutionWidth, ResolutionHeight, 24);
TargetCamera.targetTexture = renderTexture;
Texture2D screenShot = new Texture2D(ResolutionWidth, ResolutionHeight, TextureFormat.RGB24, false);
TargetCamera.Render();
RenderTexture.active = renderTexture;
screenShot.ReadPixels(new Rect(0, 0, ResolutionWidth, ResolutionHeight), 0, 0);
TargetCamera.targetTexture = null;
RenderTexture.active = null;
Destroy(renderTexture);
byte[] bytes = screenShot.EncodeToPNG();
System.IO.File.WriteAllBytes(savePath, bytes);
return savePath;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 168f80e4ec8a4314c8ca506740626021
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMScreenshot.cs
uploadId: 830868

View File

@@ -0,0 +1,177 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this component to an object to randomize its position/rotation/scale on demand or automatically
/// </summary>
#if UNITY_EDITOR
[ExecuteAlways]
#endif
public class MMTransformRandomizer : MonoBehaviour
{
/// the possible ways to automatically randomize
public enum AutoExecutionModes { Never, OnAwake, OnStart, OnEnable }
[Header("Position")]
/// whether or not to randomize position
public bool RandomizePosition = true;
/// the minimum position to apply when randomizing
[MMCondition("RandomizePosition", true)]
public Vector3 MinRandomPosition;
/// the maximum position to apply when randomizing
[MMCondition("RandomizePosition", true)]
public Vector3 MaxRandomPosition;
[Header("Rotation")]
/// whether or not to randomize rotation
public bool RandomizeRotation = true;
/// the minimum rotation to apply when randomizing (in degrees)
[MMCondition("RandomizeRotation", true)]
public Vector3 MinRandomRotation;
/// the maximum rotation to apply when randomizing (in degrees)
[MMCondition("RandomizeRotation", true)]
public Vector3 MaxRandomRotation;
[Header("Scale")]
/// whether or not to randomize scale
public bool RandomizeScale = true;
/// the minimum scale to apply when randomizing
[MMCondition("RandomizeScale", true)]
public Vector3 MinRandomScale;
/// the maximum scale to apply when randomizing
[MMCondition("RandomizeScale", true)]
public Vector3 MaxRandomScale;
[Header("Settings")]
/// whether or not to remove this component after randomizing its attributes
public bool AutoRemoveAfterRandomize = false;
/// whether or not to remove all colliders attached to this object
public bool RemoveAllColliders = false;
/// the selected auto execution mode
public AutoExecutionModes AutoExecutionMode = AutoExecutionModes.Never;
/// <summary>
/// On Awake we randomize if needed
/// </summary>
protected virtual void Awake()
{
if (Application.isPlaying && (AutoExecutionMode == AutoExecutionModes.OnAwake))
{
Randomize();
}
}
/// <summary>
/// On Start we randomize if needed
/// </summary>
protected virtual void Start()
{
if (Application.isPlaying && (AutoExecutionMode == AutoExecutionModes.OnStart))
{
Randomize();
}
}
/// <summary>
/// On Enable we randomize if needed
/// </summary>
protected virtual void OnEnable()
{
if (Application.isPlaying && (AutoExecutionMode == AutoExecutionModes.OnEnable))
{
Randomize();
}
}
/// <summary>
/// Randomizes position, rotation, scale, and cleanups if necessary
/// </summary>
public virtual void Randomize()
{
ProcessRandomizePosition();
ProcessRandomizeRotation();
ProcessRandomizeScale();
RemoveColliders();
Cleanup();
}
/// <summary>
/// Randomizes the position
/// </summary>
protected virtual void ProcessRandomizePosition()
{
if (!RandomizePosition)
{
return;
}
Vector3 randomPosition = MMMaths.RandomVector3(MinRandomPosition, MaxRandomPosition);
this.transform.localPosition += randomPosition;
}
/// <summary>
/// Randomizes the rotation
/// </summary>
protected virtual void ProcessRandomizeRotation()
{
if (!RandomizeRotation)
{
return;
}
Vector3 randomRotation = MMMaths.RandomVector3(MinRandomRotation, MaxRandomRotation);
this.transform.localRotation = Quaternion.Euler(randomRotation);
}
/// <summary>
/// Randomizes the scale
/// </summary>
protected virtual void ProcessRandomizeScale()
{
if (!RandomizeScale)
{
return;
}
Vector3 randomScale = MMMaths.RandomVector3(MinRandomScale, MaxRandomScale);
this.transform.localScale = randomScale;
}
/// <summary>
/// Removes all colliders attached to this object or its children
/// </summary>
protected virtual void RemoveColliders()
{
if (RemoveAllColliders)
{
#if UNITY_EDITOR
Collider[] colliders = this.gameObject.GetComponentsInChildren<Collider>();
foreach (Collider collider in colliders)
{
DestroyImmediate(collider);
}
#if MM_PHYSICS2D
Collider2D[] colliders2D = this.gameObject.GetComponentsInChildren<Collider2D>();
foreach (Collider2D collider2D in colliders2D)
{
DestroyImmediate(collider2D);
}
#endif
#endif
}
}
/// <summary>
/// Destroys this component
/// </summary>
protected virtual void Cleanup()
{
if (AutoRemoveAfterRandomize)
{
#if UNITY_EDITOR
DestroyImmediate(this);
#endif
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 07b798a3f371c8f4f9919515319eb447
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Accessories/MMUtilities/MMTransformRandomizer.cs
uploadId: 830868