chore: initial commit
This commit is contained in:
8
Assets/Feel/MMTools/Accessories/Editor/MMActivation.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMActivation.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06f439531d4532444a8ec2b6c5c0c7ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,108 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CustomEditor(typeof(MMTriggerAndCollision), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMTriggerAndCollisionEditor : Editor
|
||||
{
|
||||
protected SerializedProperty _CollisionLayerMask;
|
||||
protected SerializedProperty _OnCollisionEnterEvent;
|
||||
protected SerializedProperty _OnCollisionExitEvent;
|
||||
protected SerializedProperty _OnCollisionStayEvent;
|
||||
|
||||
protected SerializedProperty _TriggerLayerMask;
|
||||
protected SerializedProperty _OnTriggerEnterEvent;
|
||||
protected SerializedProperty _OnTriggerExitEvent;
|
||||
protected SerializedProperty _OnTriggerStayEvent;
|
||||
|
||||
protected SerializedProperty _Collision2DLayerMask;
|
||||
protected SerializedProperty _OnCollision2DEnterEvent;
|
||||
protected SerializedProperty _OnCollision2DExitEvent;
|
||||
protected SerializedProperty _OnCollision2DStayEvent;
|
||||
|
||||
protected SerializedProperty _Trigger2DLayerMask;
|
||||
protected SerializedProperty _OnTrigger2DEnterEvent;
|
||||
protected SerializedProperty _OnTrigger2DExitEvent;
|
||||
protected SerializedProperty _OnTrigger2DStayEvent;
|
||||
|
||||
protected bool OnCollision;
|
||||
protected bool OnTrigger;
|
||||
protected bool OnCollision2D;
|
||||
protected bool OnTrigger2D;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_CollisionLayerMask = serializedObject.FindProperty("CollisionLayerMask");
|
||||
_OnCollisionEnterEvent = serializedObject.FindProperty("OnCollisionEnterEvent");
|
||||
_OnCollisionExitEvent = serializedObject.FindProperty("OnCollisionExitEvent");
|
||||
_OnCollisionStayEvent = serializedObject.FindProperty("OnCollisionStayEvent");
|
||||
|
||||
_TriggerLayerMask = serializedObject.FindProperty("TriggerLayerMask");
|
||||
_OnTriggerEnterEvent = serializedObject.FindProperty("OnTriggerEnterEvent");
|
||||
_OnTriggerExitEvent = serializedObject.FindProperty("OnTriggerExitEvent");
|
||||
_OnTriggerStayEvent = serializedObject.FindProperty("OnTriggerStayEvent");
|
||||
|
||||
_Collision2DLayerMask = serializedObject.FindProperty("Collision2DLayerMask");
|
||||
_OnCollision2DEnterEvent = serializedObject.FindProperty("OnCollision2DEnterEvent");
|
||||
_OnCollision2DExitEvent = serializedObject.FindProperty("OnCollision2DExitEvent");
|
||||
_OnCollision2DStayEvent = serializedObject.FindProperty("OnCollision2DStayEvent");
|
||||
|
||||
_Trigger2DLayerMask = serializedObject.FindProperty("Trigger2DLayerMask");
|
||||
_OnTrigger2DEnterEvent = serializedObject.FindProperty("OnTrigger2DEnterEvent");
|
||||
_OnTrigger2DExitEvent = serializedObject.FindProperty("OnTrigger2DExitEvent");
|
||||
_OnTrigger2DStayEvent = serializedObject.FindProperty("OnTrigger2DStayEvent");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
Undo.RecordObject(target, "Modified MMTriggerAndCollision");
|
||||
|
||||
OnCollision = EditorGUILayout.Foldout(OnCollision, "OnCollision");
|
||||
|
||||
if (OnCollision)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_CollisionLayerMask);
|
||||
EditorGUILayout.PropertyField(_OnCollisionEnterEvent);
|
||||
EditorGUILayout.PropertyField(_OnCollisionExitEvent);
|
||||
EditorGUILayout.PropertyField(_OnCollisionStayEvent);
|
||||
}
|
||||
|
||||
OnTrigger = EditorGUILayout.Foldout(OnTrigger, "OnTrigger");
|
||||
|
||||
if (OnTrigger)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_TriggerLayerMask);
|
||||
EditorGUILayout.PropertyField(_OnTriggerEnterEvent);
|
||||
EditorGUILayout.PropertyField(_OnTriggerExitEvent);
|
||||
EditorGUILayout.PropertyField(_OnTriggerStayEvent);
|
||||
}
|
||||
|
||||
OnCollision2D = EditorGUILayout.Foldout(OnCollision2D, "OnCollision2D");
|
||||
|
||||
if (OnCollision2D)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_Collision2DLayerMask);
|
||||
EditorGUILayout.PropertyField(_OnCollision2DEnterEvent);
|
||||
EditorGUILayout.PropertyField(_OnCollision2DExitEvent);
|
||||
EditorGUILayout.PropertyField(_OnCollision2DStayEvent);
|
||||
}
|
||||
|
||||
OnTrigger2D = EditorGUILayout.Foldout(OnTrigger2D, "OnTrigger2D");
|
||||
|
||||
if (OnTrigger2D)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_Trigger2DLayerMask);
|
||||
EditorGUILayout.PropertyField(_OnTrigger2DEnterEvent);
|
||||
EditorGUILayout.PropertyField(_OnTrigger2DExitEvent);
|
||||
EditorGUILayout.PropertyField(_OnTrigger2DStayEvent);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58ec23fbdf517a348851de2bb297888e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMCamera.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMCamera.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07f79b5a8110a854ca5cb1aae7ef890e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,167 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for the MMScreenSafeZones component
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMAspectRatioSafeZones), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMAspectRatioSafeZonesEditor : Editor
|
||||
{
|
||||
static MMAspectRatioSafeZones safeZones;
|
||||
|
||||
/// <summary>
|
||||
/// On enable, registers to the OnSceneGUI hook
|
||||
/// </summary>
|
||||
void OnEnable()
|
||||
{
|
||||
SceneView.duringSceneGui -= OnSceneGUI;
|
||||
safeZones = (MMAspectRatioSafeZones)target;
|
||||
SceneView.duringSceneGui += OnSceneGUI;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnSceneGUI, draws center and ratios
|
||||
/// </summary>
|
||||
/// <param name="sceneView"></param>
|
||||
private static void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
DrawFrameCenter(sceneView);
|
||||
DrawRatios(sceneView);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a rectangle for each ratio
|
||||
/// </summary>
|
||||
/// <param name="sceneView"></param>
|
||||
private static void DrawRatios(SceneView sceneView)
|
||||
{
|
||||
if (!safeZones.DrawRatios)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 center = sceneView.pivot;
|
||||
|
||||
float width = sceneView.position.width;
|
||||
float height = sceneView.position.height;
|
||||
|
||||
Vector3 bottomLeft = new Vector3(center.x - width / 2f, center.y - height / 2f, 0f);
|
||||
Vector3 topRight = new Vector3(center.x + width / 2f, center.y + height / 2f, 0f);
|
||||
|
||||
Vector3 topLeft = bottomLeft;
|
||||
topLeft.y = topRight.y;
|
||||
Vector3 bottomRight = topRight;
|
||||
bottomRight.y = bottomLeft.y;
|
||||
|
||||
float size = safeZones.CameraSize;
|
||||
|
||||
// dotted lines
|
||||
float spacing = 2f;
|
||||
Color dottedLineColor = Color.white;
|
||||
dottedLineColor.a = 0.4f;
|
||||
Handles.color = dottedLineColor;
|
||||
// top
|
||||
Handles.DrawDottedLine(new Vector3(topLeft.x, center.y + size, 0f), new Vector3(topRight.x, center.y + size, 0f), spacing);
|
||||
// bottom
|
||||
Handles.DrawDottedLine(new Vector3(topLeft.x, center.y - size, 0f), new Vector3(topRight.x, center.y - size, 0f), spacing);
|
||||
|
||||
foreach (Ratio ratio in safeZones.Ratios)
|
||||
{
|
||||
if (ratio.DrawRatio)
|
||||
{
|
||||
float aspectRatio = ratio.Size.x / ratio.Size.y;
|
||||
|
||||
Handles.color = ratio.RatioColor;
|
||||
|
||||
// aspect ratio positions
|
||||
Vector3 ratioTopLeft = new Vector3(center.x - size * aspectRatio, center.y + size, 0f);
|
||||
Vector3 ratioTopRight = new Vector3(center.x + size * aspectRatio, center.y + size, 0f);
|
||||
Vector3 ratioBottomLeft = new Vector3(center.x - size * aspectRatio, center.y - size, 0f);
|
||||
Vector3 ratioBottomRight = new Vector3(center.x + size * aspectRatio, center.y - size, 0f);
|
||||
Vector3 ratioLabelPosition = ratioBottomLeft + 0.1f * Vector3.down + 0.1f * Vector3.right;
|
||||
|
||||
// draws a label under the rectangle
|
||||
GUIStyle style = new GUIStyle();
|
||||
style.normal.textColor = ratio.RatioColor;
|
||||
style.fontSize = 8;
|
||||
Handles.Label(ratioLabelPosition, ratio.Size.x + ":" + ratio.Size.y, style);
|
||||
|
||||
// draws a rectangle around the aspect ratio
|
||||
Vector3[] verts = new Vector3[] { ratioTopLeft, ratioTopRight, ratioBottomRight, ratioBottomLeft };
|
||||
Handles.DrawSolidRectangleWithOutline(verts, new Color(0, 0, 0, 0), ratio.RatioColor);
|
||||
|
||||
// draws the dead zone of that ratio
|
||||
Color zoneColor = ratio.RatioColor;
|
||||
zoneColor.a = zoneColor.a * safeZones.UnsafeZonesOpacity;
|
||||
|
||||
// top rectangle
|
||||
verts = new Vector3[] { topLeft, topRight, new Vector3(topLeft.x, ratioTopLeft.y, 0f), new Vector3(topRight.x, ratioTopRight.y, 0f) };
|
||||
Handles.DrawSolidRectangleWithOutline(verts, zoneColor, new Color(0, 0, 0, 0));
|
||||
|
||||
// bottom rectangle
|
||||
verts = new Vector3[] { bottomLeft, new Vector3(topLeft.x, ratioBottomLeft.y, 0f), new Vector3(topRight.x, ratioBottomRight.y, 0f), bottomRight };
|
||||
Handles.DrawSolidRectangleWithOutline(verts, zoneColor, new Color(0, 0, 0, 0));
|
||||
|
||||
// left rectangle
|
||||
verts = new Vector3[] { new Vector3(topLeft.x, ratioTopLeft.y, 0f), ratioTopLeft, ratioBottomLeft, new Vector3(bottomLeft.x, ratioBottomLeft.y, 0f) };
|
||||
Handles.DrawSolidRectangleWithOutline(verts, zoneColor, new Color(0, 0, 0, 0));
|
||||
|
||||
// right rectangle
|
||||
verts = new Vector3[] { new Vector3(topRight.x, ratioTopRight.y, 0f), new Vector3(bottomRight.x, ratioBottomRight.y, 0f), ratioBottomRight, ratioTopRight};
|
||||
Handles.DrawSolidRectangleWithOutline(verts, zoneColor, new Color(0, 0, 0, 0));
|
||||
|
||||
// dotted line left
|
||||
Handles.DrawDottedLine(new Vector3(ratioBottomLeft.x, topLeft.y, 0f), new Vector3(ratioTopLeft.x, bottomLeft.y, 0f), spacing);
|
||||
// dotted line right
|
||||
Handles.DrawDottedLine(new Vector3(ratioBottomRight.x, topLeft.y, 0f), new Vector3(ratioBottomRight.x, bottomLeft.y, 0f), spacing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a crosshair at the center
|
||||
/// </summary>
|
||||
/// <param name="sceneView"></param>
|
||||
private static void DrawFrameCenter(SceneView sceneView)
|
||||
{
|
||||
if (!safeZones.DrawCenterCrosshair)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 center = sceneView.pivot;
|
||||
float crossHairSize = safeZones.CenterCrosshairSize;
|
||||
|
||||
float reticleSize = crossHairSize / 10f;
|
||||
|
||||
Handles.color = safeZones.CenterCrosshairColor;
|
||||
|
||||
Vector3 crosshairTopLeft = new Vector3(center.x - crossHairSize / 2f, center.y + crossHairSize / 2f, 0f);
|
||||
Vector3 crosshairTopRight = new Vector3(center.x + crossHairSize / 2f, center.y + crossHairSize / 2f, 0f);
|
||||
Vector3 crosshairBottomLeft = new Vector3(center.x - crossHairSize / 2f, center.y - crossHairSize / 2f, 0f);
|
||||
Vector3 crosshairBottomRight = new Vector3(center.x + crossHairSize / 2f, center.y - crossHairSize / 2f, 0f);
|
||||
|
||||
// cross
|
||||
Handles.DrawLine(new Vector3(center.x, center.y + crossHairSize / 2f, 0f), new Vector3(center.x, center.y - crossHairSize / 2f, 0f));
|
||||
Handles.DrawLine(new Vector3(center.x - crossHairSize / 2f, center.y, 0f), new Vector3(center.x + crossHairSize / 2f, center.y, 0f));
|
||||
|
||||
// top left
|
||||
Handles.DrawLine(crosshairTopLeft, new Vector3(crosshairTopLeft.x + reticleSize, crosshairTopLeft.y, 0f));
|
||||
Handles.DrawLine(crosshairTopLeft, new Vector3(crosshairTopLeft.x, crosshairTopLeft.y - reticleSize, 0f));
|
||||
// top right
|
||||
Handles.DrawLine(crosshairTopRight, new Vector3(crosshairTopRight.x - reticleSize, crosshairTopRight.y, 0f));
|
||||
Handles.DrawLine(crosshairTopRight, new Vector3(crosshairTopRight.x, crosshairTopRight.y - reticleSize, 0f));
|
||||
// bottom left
|
||||
Handles.DrawLine(crosshairBottomLeft, new Vector3(crosshairBottomLeft.x + reticleSize, crosshairBottomLeft.y, 0f));
|
||||
Handles.DrawLine(crosshairBottomLeft, new Vector3(crosshairBottomLeft.x, crosshairBottomLeft.y + reticleSize, 0f));
|
||||
// bottom right
|
||||
Handles.DrawLine(crosshairBottomRight, new Vector3(crosshairBottomRight.x - reticleSize, crosshairBottomRight.y, 0f));
|
||||
Handles.DrawLine(crosshairBottomRight, new Vector3(crosshairBottomRight.x, crosshairBottomRight.y + reticleSize, 0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3318ec2edbd59284a9d8a7371e84a33e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMCollisions.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMCollisions.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d248dd8f3ec6b8408475234fb90f890
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,134 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that lets you create polygon collider 2D out of mesh filters
|
||||
/// </summary>
|
||||
public class MMMeshToPolygonCollider2D : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a PolygonCollider2D out of a meshfilter
|
||||
/// </summary>
|
||||
/// <param name="meshFilter"></param>
|
||||
private static void GeneratePolygonCollider2D(MeshFilter meshFilter)
|
||||
{
|
||||
// we validate our mesh
|
||||
if (!ValidateMesh(meshFilter))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// we grab or create our PolygonCollider2D
|
||||
PolygonCollider2D polygonCollider2D = InitializePolygonCollider2D(meshFilter);
|
||||
if (polygonCollider2D == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3[] vectors = MeshFilterToVectors(meshFilter);
|
||||
Vector2[] newPoints = VectorsToPoints(vectors);
|
||||
EditorUtility.SetDirty(polygonCollider2D);
|
||||
polygonCollider2D.SetPath(0, newPoints);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes an array of vectors and outputs points
|
||||
/// </summary>
|
||||
/// <param name="vectors"></param>
|
||||
/// <returns></returns>
|
||||
private static Vector2[] VectorsToPoints(Vector3[] vectors)
|
||||
{
|
||||
List<Vector2> newColliderVertices = new List<Vector2>();
|
||||
|
||||
for (int i = 0; i < vectors.Length; i++)
|
||||
{
|
||||
newColliderVertices.Add(new Vector2(vectors[i].x, vectors[i].y));
|
||||
}
|
||||
|
||||
Vector2[] newPoints = newColliderVertices.Distinct().ToArray();
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns a meshfilter into an array of vectors
|
||||
/// </summary>
|
||||
/// <param name="meshFilter"></param>
|
||||
/// <returns></returns>
|
||||
private static Vector3[] MeshFilterToVectors(MeshFilter meshFilter)
|
||||
{
|
||||
List<Vector3> vertices = new List<Vector3>();
|
||||
meshFilter.sharedMesh.GetVertices(vertices);
|
||||
|
||||
List<MMGeometry.MMEdge> boundaryPath = MMGeometry.GetEdges(meshFilter.sharedMesh.triangles).FindBoundary().SortEdges();
|
||||
|
||||
Vector3[] vectors = new Vector3[boundaryPath.Count];
|
||||
for (int i = 0; i < boundaryPath.Count; i++)
|
||||
{
|
||||
vectors[i] = vertices[boundaryPath[i].Vertice1];
|
||||
}
|
||||
|
||||
return vectors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grabs or creates a polygon collider 2D
|
||||
/// </summary>
|
||||
/// <param name="meshFilter"></param>
|
||||
/// <returns></returns>
|
||||
private static PolygonCollider2D InitializePolygonCollider2D(MeshFilter meshFilter)
|
||||
{
|
||||
PolygonCollider2D polygonCollider2D = meshFilter.GetComponent<PolygonCollider2D>();
|
||||
if (polygonCollider2D == null)
|
||||
{
|
||||
polygonCollider2D = meshFilter.gameObject.AddComponent<PolygonCollider2D>();
|
||||
}
|
||||
polygonCollider2D.pathCount = 1;
|
||||
return polygonCollider2D;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes sure that
|
||||
/// </summary>
|
||||
/// <param name="meshFilter"></param>
|
||||
/// <returns></returns>
|
||||
private static bool ValidateMesh(MeshFilter meshFilter)
|
||||
{
|
||||
if (meshFilter.sharedMesh == null)
|
||||
{
|
||||
Debug.LogWarning("[MMMeshToPolygonCollider2D] "
|
||||
+ meshFilter.gameObject.name
|
||||
+ " needs to have at least a mesh set on its mesh filter component.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method meant to be called via the Tools menu, that will go through all mesh colliders on an object and generate a polygon collider2D out of it
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Collisions/Generate PolygonCollider2D", false, 601)]
|
||||
public static void GeneratePolygonCollider2DMenu()
|
||||
{
|
||||
Transform activeTransform = Selection.activeTransform;
|
||||
if (activeTransform == null)
|
||||
{
|
||||
Debug.LogWarning("[MMMeshToPolygonCollider2D] You need to select a gameobject first.");
|
||||
return;
|
||||
}
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(activeTransform.gameObject.scene);
|
||||
MeshFilter[] meshFilters = activeTransform.GetComponentsInChildren<MeshFilter>();
|
||||
|
||||
foreach (MeshFilter meshFilter in meshFilters)
|
||||
{
|
||||
GeneratePolygonCollider2D(meshFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff6c7676065e39545a4f7ccb2f5d67b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMCurves.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMCurves.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c87e76a9104d58848990d987427637b3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14261
Assets/Feel/MMTools/Accessories/Editor/MMCurves/MMAntiCurves.curves
Normal file
14261
Assets/Feel/MMTools/Accessories/Editor/MMCurves/MMAntiCurves.curves
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9bd36e0fdcb17346bb804d148559eb2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14182
Assets/Feel/MMTools/Accessories/Editor/MMCurves/MMCurves.curves
Normal file
14182
Assets/Feel/MMTools/Accessories/Editor/MMCurves/MMCurves.curves
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7ae097ceef007248a49d4df212cceb7
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom editor displaying a foldable list of MMFeedbacks, a dropdown to add more, as well as test buttons to test your feedbacks at runtime
|
||||
/// </summary>
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(MMPlotter), true)]
|
||||
public class MMPlotterEditor : Editor
|
||||
{
|
||||
protected string[] _typeDisplays;
|
||||
protected string[] _excludedProperties = new string[] { "TweenMethod", "m_Script" };
|
||||
|
||||
protected MMPlotter _mmPlotter;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_mmPlotter = target as MMPlotter;
|
||||
_typeDisplays = _mmPlotter.GetMethodsList();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
Undo.RecordObject(target, "Modified Plotter");
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Tween Method", EditorStyles.boldLabel);
|
||||
|
||||
_mmPlotter.TweenMethodIndex = EditorGUILayout.Popup("Tween Method", _mmPlotter.TweenMethodIndex, _typeDisplays, EditorStyles.popup);
|
||||
|
||||
//int newItem = EditorGUILayout.Popup(0, _typeDisplays) - 1;
|
||||
//DrawDefaultInspector();
|
||||
DrawPropertiesExcluding(serializedObject, _excludedProperties);
|
||||
|
||||
if (GUILayout.Button("Draw Graph"))
|
||||
{
|
||||
_mmPlotter.DrawGraph();
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e2bca92e67ccd243a920ed5311a183e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMGUI.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMGUI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec2c09d8ce924514f83d373d66c61bd2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEditor;
|
||||
|
||||
#if MM_UI
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(MMHealthBar),true)]
|
||||
/// <summary>
|
||||
/// Custom editor for health bars (mostly a switch for prefab based / drawn bars
|
||||
/// </summary>
|
||||
public class HealthBarEditor : Editor
|
||||
{
|
||||
public MMHealthBar HealthBarTarget
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MMHealthBar)target;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
switch (HealthBarTarget.HealthBarType)
|
||||
{
|
||||
case MMHealthBar.HealthBarTypes.Prefab:
|
||||
Editor.DrawPropertiesExcluding(serializedObject, new string[] {"TargetProgressBar", "NestDrawnHealthBar", "Billboard", "FollowTargetMode", "Size","BackgroundPadding", "SortingLayerName", "InitialRotationAngles", "ForegroundColor", "DelayedColor", "BorderColor", "BackgroundColor", "Delay", "LerpFrontBar", "LerpFrontBarSpeed", "LerpDelayedBar", "LerpDelayedBarSpeed", "BumpScaleOnChange", "BumpDuration", "BumpAnimationCurve" });
|
||||
break;
|
||||
case MMHealthBar.HealthBarTypes.Drawn:
|
||||
Editor.DrawPropertiesExcluding(serializedObject, new string[] {"TargetProgressBar", "HealthBarPrefab" });
|
||||
break;
|
||||
case MMHealthBar.HealthBarTypes.Existing:
|
||||
Editor.DrawPropertiesExcluding(serializedObject, new string[] {"HealthBarPrefab", "NestDrawnHealthBar", "Billboard", "FollowTargetMode", "Size","BackgroundPadding", "SortingLayerName", "InitialRotationAngles", "ForegroundColor", "DelayedColor", "BorderColor", "BackgroundColor", "Delay", "LerpFrontBar", "LerpFrontBarSpeed", "LerpDelayedBar", "LerpDelayedBarSpeed", "BumpScaleOnChange", "BumpDuration", "BumpAnimationCurve" });
|
||||
break;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cb989d69836540e780467ed8454742c
|
||||
timeCreated: 1470860033
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMGizmos.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMGizmos.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8270d09483571e4991c729b5abcc708
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
384
Assets/Feel/MMTools/Accessories/Editor/MMGizmos/MMGizmoEditor.cs
Normal file
384
Assets/Feel/MMTools/Accessories/Editor/MMGizmos/MMGizmoEditor.cs
Normal file
@@ -0,0 +1,384 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// a custom editor for the MMGizmo component
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMGizmo), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMGizmoEditor : Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Lets you press G when in scene view to toggle gizmos on or off
|
||||
/// </summary>
|
||||
[Shortcut("Toggle Gizmos", typeof(SceneView), KeyCode.G, displayName = "ToggleGizmos")]
|
||||
public static void ToggleGizmos()
|
||||
{
|
||||
SceneView.lastActiveSceneView.drawGizmos = !SceneView.lastActiveSceneView.drawGizmos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the target object is selected, we draw our gizmos
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
/// <param name="gizmoType"></param>
|
||||
[DrawGizmo(GizmoType.Selected)]
|
||||
private static void DrawGizmoSelected(MMGizmo mmGizmo, GizmoType gizmoType)
|
||||
{
|
||||
if (!mmGizmo.DisplayGizmo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawGizmos(mmGizmo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the target object is not selected, we draw our gizmos if needed
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
/// <param name="gizmoType"></param>
|
||||
[DrawGizmo(GizmoType.NonSelected)]
|
||||
private static void DrawGizmoNonSelected(MMGizmo mmGizmo, GizmoType gizmoType)
|
||||
{
|
||||
if (!mmGizmo.DisplayGizmo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mmGizmo.DisplayMode != MMGizmo.DisplayModes.Always)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawGizmos(mmGizmo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws gizmos and text
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
private static void DrawGizmos(MMGizmo mmGizmo)
|
||||
{
|
||||
if (!mmGizmo.Initialized)
|
||||
{
|
||||
Initialization(mmGizmo);
|
||||
}
|
||||
|
||||
if (TestDistance(mmGizmo, mmGizmo.ViewDistance))
|
||||
{
|
||||
Gizmos.color = mmGizmo.GizmoColor;
|
||||
Gizmos.matrix = mmGizmo.transform.localToWorldMatrix;
|
||||
|
||||
switch (mmGizmo.GizmoType)
|
||||
{
|
||||
case MMGizmo.GizmoTypes.Collider:
|
||||
DrawColliderGizmo(mmGizmo);
|
||||
break;
|
||||
case MMGizmo.GizmoTypes.Position:
|
||||
DrawPositionGizmo(mmGizmo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DrawText(mmGizmo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether or not gizmos should be drawn based on distance to the scene camera
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
/// <param name="viewDistance"></param>
|
||||
/// <returns></returns>
|
||||
private static bool TestDistance(MMGizmo mmGizmo, float viewDistance)
|
||||
{
|
||||
float distanceToCamera = 0f;
|
||||
|
||||
if (SceneView.currentDrawingSceneView == null)
|
||||
{
|
||||
distanceToCamera = Vector3.Distance(mmGizmo.transform.position, Camera.main.transform.position);
|
||||
return (distanceToCamera < viewDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
distanceToCamera = Vector3.Distance(mmGizmo.transform.position, SceneView.currentDrawingSceneView.camera.transform.position);
|
||||
return (distanceToCamera < viewDistance);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Enable we initialize our gizmo
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
Initialization(target as MMGizmo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On validate we initialize our gizmo
|
||||
/// </summary>
|
||||
protected void OnValidate()
|
||||
{
|
||||
Initialization(target as MMGizmo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the gizmo, caching components, values, and inits the GUIStyle
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
private static void Initialization(MMGizmo mmGizmo)
|
||||
{
|
||||
mmGizmo._sphereCollider = mmGizmo.gameObject.GetComponent<SphereCollider>();
|
||||
mmGizmo._boxCollider = mmGizmo.gameObject.GetComponent<BoxCollider>();
|
||||
mmGizmo._meshCollider = mmGizmo.gameObject.GetComponent<MeshCollider>();
|
||||
mmGizmo._circleCollider2D = mmGizmo.gameObject.GetComponent<CircleCollider2D>();
|
||||
mmGizmo._boxCollider2D = mmGizmo.gameObject.GetComponent<BoxCollider2D>();
|
||||
|
||||
mmGizmo._sphereColliderNotNull = (mmGizmo._sphereCollider != null);
|
||||
mmGizmo._boxColliderNotNull = (mmGizmo._boxCollider != null);
|
||||
mmGizmo._meshColliderNotNull = (mmGizmo._meshCollider != null);
|
||||
mmGizmo._circleCollider2DNotNull = (mmGizmo._circleCollider2D != null);
|
||||
mmGizmo._boxCollider2DNotNull = (mmGizmo._boxCollider2D != null);
|
||||
|
||||
mmGizmo._vector3Zero = Vector3.zero;
|
||||
mmGizmo._textureRect = new Rect(0f, 0f, mmGizmo.TextureSize.x, mmGizmo.TextureSize.y);
|
||||
mmGizmo._positionTextureNotNull = (mmGizmo.PositionTexture != null);
|
||||
|
||||
mmGizmo._textGUIStyle = new GUIStyle();
|
||||
mmGizmo._textGUIStyle.normal.textColor = mmGizmo.TextColor;
|
||||
mmGizmo._textGUIStyle.fontSize = mmGizmo.TextSize;
|
||||
mmGizmo._textGUIStyle.fontStyle = mmGizmo.TextFontStyle;
|
||||
mmGizmo._textGUIStyle.padding = new RectOffset((int)mmGizmo.TextPadding.x, (int)mmGizmo.TextPadding.y, (int)mmGizmo.TextPadding.z, (int)mmGizmo.TextPadding.w);
|
||||
mmGizmo._textGUIStyle.normal.background = MMGUI.MakeTex(600, 100, mmGizmo.TextBackgroundColor);
|
||||
|
||||
mmGizmo.Initialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a gizmo for the associated collider
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
private static void DrawColliderGizmo(MMGizmo mmGizmo)
|
||||
{
|
||||
if (mmGizmo._sphereColliderNotNull)
|
||||
{
|
||||
if (mmGizmo.ColliderRenderType == MMGizmo.ColliderRenderTypes.Full)
|
||||
{
|
||||
Gizmos.DrawSphere(ComputeGizmoPosition(mmGizmo, mmGizmo._sphereCollider.center), mmGizmo._sphereCollider.radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawWireSphere(ComputeGizmoPosition(mmGizmo, mmGizmo._sphereCollider.center), mmGizmo._sphereCollider.radius);
|
||||
}
|
||||
}
|
||||
|
||||
if (mmGizmo._boxColliderNotNull)
|
||||
{
|
||||
if (mmGizmo.ColliderRenderType == MMGizmo.ColliderRenderTypes.Full)
|
||||
{
|
||||
Gizmos.DrawCube(ComputeGizmoPosition(mmGizmo, mmGizmo._boxCollider.center), mmGizmo._boxCollider.size);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawWireCube(ComputeGizmoPosition(mmGizmo, mmGizmo._boxCollider.center), mmGizmo._boxCollider.size);
|
||||
}
|
||||
}
|
||||
|
||||
if (mmGizmo._circleCollider2DNotNull)
|
||||
{
|
||||
if (mmGizmo.ColliderRenderType == MMGizmo.ColliderRenderTypes.Full)
|
||||
{
|
||||
Gizmos.DrawSphere((Vector3)ComputeGizmoPosition(mmGizmo, mmGizmo._circleCollider2D.offset), mmGizmo._circleCollider2D.radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawWireSphere((Vector3)ComputeGizmoPosition(mmGizmo, mmGizmo._circleCollider2D.offset), mmGizmo._circleCollider2D.radius);
|
||||
}
|
||||
}
|
||||
|
||||
if (mmGizmo._boxCollider2DNotNull)
|
||||
{
|
||||
Vector3 gizmoSize = new Vector3();
|
||||
gizmoSize.x = mmGizmo._boxCollider2D.size.x ;
|
||||
gizmoSize.y = mmGizmo._boxCollider2D.size.y ;
|
||||
gizmoSize.z = 0.1f;
|
||||
if (mmGizmo.ColliderRenderType == MMGizmo.ColliderRenderTypes.Full)
|
||||
{
|
||||
Gizmos.DrawCube(ComputeGizmoPosition(mmGizmo, mmGizmo._boxCollider2D.offset), gizmoSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawWireCube(ComputeGizmoPosition(mmGizmo, mmGizmo._boxCollider2D.offset), gizmoSize);
|
||||
}
|
||||
}
|
||||
|
||||
if (mmGizmo._meshColliderNotNull)
|
||||
{
|
||||
if (mmGizmo.ColliderRenderType == MMGizmo.ColliderRenderTypes.Full)
|
||||
{
|
||||
Gizmos.DrawMesh(mmGizmo._meshCollider.sharedMesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawWireMesh(mmGizmo._meshCollider.sharedMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a position gizmo
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
private static void DrawPositionGizmo(MMGizmo mmGizmo)
|
||||
{
|
||||
switch (mmGizmo.PositionMode)
|
||||
{
|
||||
case MMGizmo.PositionModes.Point:
|
||||
MMDebug.DrawGizmoPoint(ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero), mmGizmo.GizmoColor, mmGizmo.PositionSize);
|
||||
break;
|
||||
case MMGizmo.PositionModes.Cube:
|
||||
Gizmos.DrawCube(ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero), Vector3.one * mmGizmo.PositionSize);
|
||||
break;
|
||||
case MMGizmo.PositionModes.Sphere:
|
||||
Gizmos.DrawSphere(ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero), mmGizmo.PositionSize);
|
||||
break;
|
||||
case MMGizmo.PositionModes.WireCube:
|
||||
Gizmos.DrawWireCube(ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero), Vector3.one * mmGizmo.PositionSize);
|
||||
break;
|
||||
case MMGizmo.PositionModes.WireSphere:
|
||||
Gizmos.DrawWireSphere(ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero), mmGizmo.PositionSize);
|
||||
break;
|
||||
case MMGizmo.PositionModes.Texture:
|
||||
if (mmGizmo._positionTextureNotNull)
|
||||
{
|
||||
Handles.BeginGUI();
|
||||
mmGizmo._worldToGUIPosition = HandleUtility.WorldToGUIPoint(ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false));
|
||||
mmGizmo._textureRect = new Rect(mmGizmo._worldToGUIPosition.x - mmGizmo.TextureSize.x/2f, mmGizmo._worldToGUIPosition.y - mmGizmo.TextureSize.y/2f, mmGizmo.TextureSize.x, mmGizmo.TextureSize.y);
|
||||
GUI.Label(mmGizmo._textureRect, mmGizmo.PositionTexture);
|
||||
Handles.EndGUI();
|
||||
}
|
||||
break;
|
||||
case MMGizmo.PositionModes.Arrows:
|
||||
Handles.color = Handles.xAxisColor;
|
||||
Handles.ArrowHandleCap(0, ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false),
|
||||
Quaternion.LookRotation(mmGizmo.transform.right, mmGizmo.transform.up), mmGizmo.PositionSize, EventType.Repaint);
|
||||
Handles.color = Handles.yAxisColor;
|
||||
Handles.ArrowHandleCap(0, ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false),
|
||||
Quaternion.LookRotation(mmGizmo.transform.up, mmGizmo.transform.up), mmGizmo.PositionSize, EventType.Repaint);
|
||||
Handles.color = Handles.zAxisColor;
|
||||
Handles.ArrowHandleCap(0, ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false),
|
||||
Quaternion.LookRotation(mmGizmo.transform.forward, mmGizmo.transform.up), mmGizmo.PositionSize, EventType.Repaint);
|
||||
break;
|
||||
case MMGizmo.PositionModes.RightArrow:
|
||||
Handles.color = mmGizmo.GizmoColor;
|
||||
Handles.ArrowHandleCap(0, ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false),
|
||||
Quaternion.LookRotation(mmGizmo.transform.right, mmGizmo.transform.up), mmGizmo.PositionSize, EventType.Repaint);
|
||||
break;
|
||||
case MMGizmo.PositionModes.UpArrow:
|
||||
Handles.color = mmGizmo.GizmoColor;
|
||||
Handles.ArrowHandleCap(0, ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false),
|
||||
Quaternion.LookRotation(mmGizmo.transform.up, mmGizmo.transform.up), mmGizmo.PositionSize, EventType.Repaint);
|
||||
break;
|
||||
case MMGizmo.PositionModes.ForwardArrow:
|
||||
Handles.color = mmGizmo.GizmoColor;
|
||||
Handles.ArrowHandleCap(0, ComputeGizmoPosition(mmGizmo, mmGizmo.transform.position, false),
|
||||
Quaternion.LookRotation(mmGizmo.transform.forward, mmGizmo.transform.up), mmGizmo.PositionSize, EventType.Repaint);
|
||||
break;
|
||||
case MMGizmo.PositionModes.Lines:
|
||||
Vector3 origin = ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero);
|
||||
Vector3 destination = origin + Vector3.right * mmGizmo.PositionSize;
|
||||
Gizmos.DrawLine(origin, destination);
|
||||
destination = origin + Vector3.up * mmGizmo.PositionSize;
|
||||
Gizmos.DrawLine(origin, destination);
|
||||
destination = origin + Vector3.forward * mmGizmo.PositionSize;
|
||||
Gizmos.DrawLine(origin, destination);
|
||||
break;
|
||||
case MMGizmo.PositionModes.RightLine:
|
||||
Vector3 rightOrigin = ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero);
|
||||
Vector3 rightDestination = rightOrigin + Vector3.right * mmGizmo.PositionSize;
|
||||
Gizmos.DrawLine(rightOrigin, rightDestination);
|
||||
break;
|
||||
case MMGizmo.PositionModes.UpLine:
|
||||
Vector3 upOrigin = ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero);
|
||||
Vector3 upDestination = upOrigin + Vector3.up * mmGizmo.PositionSize;
|
||||
Gizmos.DrawLine(upOrigin, upDestination);
|
||||
break;
|
||||
case MMGizmo.PositionModes.ForwardLine:
|
||||
Vector3 fwdOrigin = ComputeGizmoPosition(mmGizmo, mmGizmo._vector3Zero);
|
||||
Vector3 fwdDestination = fwdOrigin + Vector3.forward * mmGizmo.PositionSize;
|
||||
Gizmos.DrawLine(fwdOrigin, fwdDestination);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws our gizmo text
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
private static void DrawText(MMGizmo mmGizmo)
|
||||
{
|
||||
if (!mmGizmo.DisplayText)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TestDistance(mmGizmo, mmGizmo.TextMaxDistance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mmGizmo.TextMode)
|
||||
{
|
||||
case MMGizmo.TextModes.GameObjectName:
|
||||
mmGizmo._textToDisplay = mmGizmo.gameObject.name;
|
||||
break;
|
||||
case MMGizmo.TextModes.CustomText:
|
||||
mmGizmo._textToDisplay = mmGizmo.TextToDisplay;
|
||||
break;
|
||||
case MMGizmo.TextModes.Position:
|
||||
mmGizmo._textToDisplay = mmGizmo.transform.position.ToString();
|
||||
break;
|
||||
case MMGizmo.TextModes.Rotation:
|
||||
mmGizmo._textToDisplay = mmGizmo.transform.rotation.ToString();
|
||||
break;
|
||||
case MMGizmo.TextModes.Scale:
|
||||
mmGizmo._textToDisplay = mmGizmo.transform.localScale.ToString();
|
||||
break;
|
||||
case MMGizmo.TextModes.Property:
|
||||
if (mmGizmo.TargetProperty.PropertyFound)
|
||||
{
|
||||
mmGizmo._textToDisplay = mmGizmo.TargetProperty.GetRawValue().ToString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (mmGizmo._textToDisplay != "")
|
||||
{
|
||||
Handles.Label(mmGizmo.transform.position + mmGizmo.TextOffset, mmGizmo._textToDisplay, mmGizmo._textGUIStyle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the position at which to draw the gizmo
|
||||
/// </summary>
|
||||
/// <param name="mmGizmo"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="relativeLock"></param>
|
||||
/// <returns></returns>
|
||||
private static Vector3 ComputeGizmoPosition(MMGizmo mmGizmo, Vector3 position, bool relativeLock = true)
|
||||
{
|
||||
mmGizmo._newPosition = position + mmGizmo.GizmoOffset;
|
||||
|
||||
if (mmGizmo.LockX || mmGizmo.LockY || mmGizmo.LockZ)
|
||||
{
|
||||
Vector3 mmGizmoNewPosition = mmGizmo._newPosition;
|
||||
if (mmGizmo.LockX) { mmGizmoNewPosition.x = relativeLock ? - mmGizmo.transform.position.x + mmGizmo.LockedX : mmGizmo.LockedX; }
|
||||
if (mmGizmo.LockY) { mmGizmoNewPosition.y = relativeLock ? - mmGizmo.transform.position.y + mmGizmo.LockedY : mmGizmo.LockedY; }
|
||||
if (mmGizmo.LockZ) { mmGizmoNewPosition.z = relativeLock ? - mmGizmo.transform.position.z + mmGizmo.LockedZ : mmGizmo.LockedZ; }
|
||||
mmGizmo._newPosition = mmGizmoNewPosition;
|
||||
}
|
||||
|
||||
return mmGizmo._newPosition;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b4b64ec300cb6948b1022cd5e3311c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80980790afe30ae46a76dc36a8ae3fbc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A maintenance class that removes all empty directories from a project via a menu item
|
||||
/// </summary>
|
||||
public class MMCleanEmptyFolders : MonoBehaviour
|
||||
{
|
||||
static string _consoleLog = "";
|
||||
static List<DirectoryInfo> _listOfEmptyDirectories = new List<DirectoryInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Parses the project for empty directories and removes them, as well as their associated meta file
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Cleanup empty folders", false, 504)]
|
||||
protected static void CleanupMissingScripts()
|
||||
{
|
||||
_listOfEmptyDirectories.Clear();
|
||||
var assetsDir = Application.dataPath + Path.DirectorySeparatorChar;
|
||||
GetEmptyDirectories(new DirectoryInfo(assetsDir), _listOfEmptyDirectories);
|
||||
|
||||
if (0 < _listOfEmptyDirectories.Count)
|
||||
{
|
||||
_consoleLog = "[MMCleanEmptyFolders] Removed "+ _listOfEmptyDirectories.Count + " empty directories:\n";
|
||||
foreach (var d in _listOfEmptyDirectories)
|
||||
{
|
||||
_consoleLog += "· "+ d.FullName.Replace(assetsDir, "") + "\n";
|
||||
FileUtil.DeleteFileOrDirectory(d.FullName);
|
||||
FileUtil.DeleteFileOrDirectory(d.FullName+".meta");
|
||||
}
|
||||
|
||||
MMDebug.DebugLogInfo(_consoleLog);
|
||||
_consoleLog = "";
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if a directory is empty and updates a list of empty directories
|
||||
/// </summary>
|
||||
/// <param name="directory"></param>
|
||||
/// <param name="listOfEmptyDirectories"></param>
|
||||
/// <returns></returns>
|
||||
static bool GetEmptyDirectories(DirectoryInfo directory, List<DirectoryInfo> listOfEmptyDirectories)
|
||||
{
|
||||
bool directoryIsEmpty = true;
|
||||
directoryIsEmpty = (directory.GetDirectories().Count(x => !GetEmptyDirectories(x, listOfEmptyDirectories)) == 0) && (directory.GetFiles("*.*").All(x => x.Extension == ".meta"));
|
||||
|
||||
if (directoryIsEmpty)
|
||||
{
|
||||
listOfEmptyDirectories.Add(directory);
|
||||
}
|
||||
|
||||
return directoryIsEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eef8a54b228d3d148b605064c04e66a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// This class lets you clean all missing scripts on a selection of gameobjects
|
||||
/// </summary>
|
||||
public class MMCleanupMissingScripts : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Processes the cleaning of gameobjects for all missing scripts on them
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Cleanup missing scripts on selected GameObjects", false, 504)]
|
||||
protected static void CleanupMissingScripts()
|
||||
{
|
||||
Object[] collectedDeepHierarchy = EditorUtility.CollectDeepHierarchy(Selection.gameObjects);
|
||||
int removedComponentsCounter = 0;
|
||||
int gameobjectsAffectedCounter = 0;
|
||||
foreach (Object targetObject in collectedDeepHierarchy)
|
||||
{
|
||||
if (targetObject is GameObject gameObject)
|
||||
{
|
||||
int amountOfMissingScripts = GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(gameObject);
|
||||
if (amountOfMissingScripts > 0)
|
||||
{
|
||||
Undo.RegisterCompleteObjectUndo(gameObject, "Removing missing scripts");
|
||||
GameObjectUtility.RemoveMonoBehavioursWithMissingScript(gameObject);
|
||||
removedComponentsCounter += amountOfMissingScripts;
|
||||
gameobjectsAffectedCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
MMDebug.DebugLogInfo("[MMCleanupMissingScripts] Removed " + removedComponentsCounter + " missing scripts from " + gameobjectsAffectedCounter + " GameObjects");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05ed97bf9ce684b47ab50ba3bf13134e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
// Original FindMissingScriptsRecursively script by SimTex and Clement
|
||||
// http://wiki.unity3d.com/index.php?title=FindMissingScripts
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
public class MMFindMissingScriptsRecursively : EditorWindow
|
||||
{
|
||||
static int go_count = 0, components_count = 0, missing_count = 0;
|
||||
|
||||
[MenuItem("Tools/More Mountains/Find missing scripts recursively", false, 505)]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
EditorWindow.GetWindow(typeof(MMFindMissingScriptsRecursively));
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void OnGUI()
|
||||
{
|
||||
if (GUILayout.Button("Find Missing Scripts in selected GameObjects"))
|
||||
{
|
||||
FindInSelected();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void FindInSelected()
|
||||
{
|
||||
GameObject[] go = Selection.gameObjects;
|
||||
go_count = 0;
|
||||
components_count = 0;
|
||||
missing_count = 0;
|
||||
foreach (GameObject g in go)
|
||||
{
|
||||
FindInGO(g);
|
||||
}
|
||||
Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count));
|
||||
}
|
||||
|
||||
private static void FindInGO(GameObject g)
|
||||
{
|
||||
go_count++;
|
||||
Component[] components = g.GetComponents<Component>();
|
||||
for (int i = 0; i < components.Length; i++)
|
||||
{
|
||||
components_count++;
|
||||
if (components[i] == null)
|
||||
{
|
||||
missing_count++;
|
||||
string s = g.name;
|
||||
Transform t = g.transform;
|
||||
while (t.parent != null)
|
||||
{
|
||||
s = t.parent.name +"/"+s;
|
||||
t = t.parent;
|
||||
}
|
||||
Debug.Log (s + " has an empty script attached in position: " + i, g);
|
||||
}
|
||||
}
|
||||
// Now recurse through each child GO (if there are any):
|
||||
foreach (Transform childT in g.transform)
|
||||
{
|
||||
FindInGO(childT.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c87833dd08a8c842823386dde78cb2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,283 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// As static class that lets you look for missing scripts on any prefab in your project, or for prefabs equipped with a certain type of MonoBehaviour
|
||||
/// </summary>
|
||||
public class MMFindPrefabsByMono : EditorWindow
|
||||
{
|
||||
protected Vector2 _scrollView;
|
||||
protected string[] _tabs = new string[] { "Find prefabs with missing components", "Find prefabs by MonoBehaviour" };
|
||||
protected int _selectedTab;
|
||||
protected int _lastSelectedTab = -1;
|
||||
protected MonoScript _searchedMonoBehaviour;
|
||||
protected MonoScript _lastSearchedMonoBehaviour;
|
||||
protected string _searchedMonoBehaviourName = "";
|
||||
protected List<string> _resultsList;
|
||||
|
||||
static GUIStyle _padded;
|
||||
static GUIStyle _horizontalPadded;
|
||||
static int _horizontalPadding = 20;
|
||||
static int _verticalPadding = 20;
|
||||
static RectOffset _padding;
|
||||
static RectOffset _horizontalPaddingOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Menu bound method
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Prefab Finder", false, 504)]
|
||||
public static void MenuAction()
|
||||
{
|
||||
OpenWindow();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens and resizes the window
|
||||
/// </summary>
|
||||
public static void OpenWindow()
|
||||
{
|
||||
InitializePaddingAndStyles();
|
||||
MMFindPrefabsByMono window = (MMFindPrefabsByMono)EditorWindow.GetWindow(typeof(MMFindPrefabsByMono));
|
||||
window.position = new Rect(400, 400, 800, 600);
|
||||
window.titleContent = new GUIContent("MM Prefabs Finder");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes padding variables and GUI styles
|
||||
/// </summary>
|
||||
static void InitializePaddingAndStyles()
|
||||
{
|
||||
if (_padding == null)
|
||||
{
|
||||
_padding = new RectOffset(_horizontalPadding, _horizontalPadding, _verticalPadding, _verticalPadding);
|
||||
_horizontalPaddingOnly = new RectOffset(_horizontalPadding, _horizontalPadding, 0, 0);
|
||||
_padded = new GUIStyle
|
||||
{
|
||||
name = "padded",
|
||||
padding = _padding
|
||||
};
|
||||
_horizontalPadded = new GUIStyle
|
||||
{
|
||||
name = "horizontalPadded",
|
||||
padding = _horizontalPaddingOnly
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws tab buttons
|
||||
/// </summary>
|
||||
protected virtual void DrawTabs()
|
||||
{
|
||||
GUI.skin.box.padding = _padding;
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Space(10);
|
||||
_selectedTab = GUILayout.Toolbar(_selectedTab, _tabs);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detects changes in tabs selection
|
||||
/// </summary>
|
||||
protected virtual void HandleTabsChange()
|
||||
{
|
||||
if (_lastSelectedTab != _selectedTab)
|
||||
{
|
||||
_lastSelectedTab = _selectedTab;
|
||||
_resultsList = new List<string>();
|
||||
_searchedMonoBehaviourName = _searchedMonoBehaviour == null ? "" : _searchedMonoBehaviour.name;
|
||||
_lastSearchedMonoBehaviour = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the content of the selected tab
|
||||
/// </summary>
|
||||
protected virtual void DrawSelectedTab()
|
||||
{
|
||||
switch (_selectedTab)
|
||||
{
|
||||
case 0:
|
||||
DrawSearchMissing();
|
||||
break;
|
||||
case 1:
|
||||
DrawSearchByMonoBehaviour();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the search by mono form
|
||||
/// </summary>
|
||||
protected virtual void DrawSearchByMonoBehaviour()
|
||||
{
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Space(20);
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label("Select a MonoBehaviour to search for:");
|
||||
_searchedMonoBehaviour = (MonoScript)EditorGUILayout.ObjectField(_searchedMonoBehaviour, typeof(MonoScript), false);
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.Space(10);
|
||||
|
||||
if (_searchedMonoBehaviour != _lastSearchedMonoBehaviour)
|
||||
{
|
||||
string[] allPrefabsInProject = GetAllPrefabsInProject();
|
||||
|
||||
_lastSearchedMonoBehaviour = _searchedMonoBehaviour;
|
||||
_searchedMonoBehaviourName = _searchedMonoBehaviour.name;
|
||||
AssetDatabase.SaveAssets();
|
||||
string searchedMonoBehaviourPath = AssetDatabase.GetAssetPath(_searchedMonoBehaviour);
|
||||
_resultsList = new List<string>();
|
||||
foreach (string prefab in allPrefabsInProject)
|
||||
{
|
||||
string[] pathName = new string[] { prefab };
|
||||
string[] monoDependenciesPaths = AssetDatabase.GetDependencies(pathName, false);
|
||||
foreach (string monoDependencyPath in monoDependenciesPaths)
|
||||
{
|
||||
if (monoDependencyPath == searchedMonoBehaviourPath)
|
||||
{
|
||||
_resultsList.Add(prefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the search missing form
|
||||
/// </summary>
|
||||
protected virtual void DrawSearchMissing()
|
||||
{
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Space(20);
|
||||
if (GUILayout.Button("Search the project for prefabs with missing scripts"))
|
||||
{
|
||||
string[] allPrefabs = GetAllPrefabsInProject();
|
||||
_resultsList = new List<string>();
|
||||
foreach (string prefab in allPrefabs)
|
||||
{
|
||||
UnityEngine.Object asset = AssetDatabase.LoadMainAssetAtPath(prefab);
|
||||
GameObject assetGameObject;
|
||||
try
|
||||
{
|
||||
assetGameObject = (GameObject)asset;
|
||||
Component[] components = assetGameObject.GetComponentsInChildren<Component>(true);
|
||||
foreach (Component component in components)
|
||||
{
|
||||
if (component == null)
|
||||
{
|
||||
_resultsList.Add(prefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
MMDebug.DebugLogInfo("An error occured with prefab " + prefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the result list
|
||||
/// </summary>
|
||||
protected virtual void DrawResultsList()
|
||||
{
|
||||
GUILayout.BeginHorizontal(_padded);
|
||||
if (_resultsList != null)
|
||||
{
|
||||
if (_resultsList.Count == 0)
|
||||
{
|
||||
switch (_selectedTab)
|
||||
{
|
||||
case 0:
|
||||
GUILayout.Label("No prefabs have missing components.", EditorStyles.boldLabel);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!string.IsNullOrEmpty(_searchedMonoBehaviourName))
|
||||
{
|
||||
GUILayout.Label("No prefabs use component " + _searchedMonoBehaviourName, EditorStyles.boldLabel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
GUILayout.EndHorizontal(); // end padded
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_selectedTab)
|
||||
{
|
||||
case 0:
|
||||
GUILayout.Label("These prefabs have missing components :", EditorStyles.boldLabel);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
GUILayout.Label("MonoBehaviour " + _searchedMonoBehaviourName + " was found in these prefabs :", EditorStyles.boldLabel);
|
||||
break;
|
||||
}
|
||||
GUILayout.EndHorizontal(); // end padded
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.skin.scrollView.padding = _padding;
|
||||
_scrollView = GUILayout.BeginScrollView(_scrollView);
|
||||
foreach (string s in _resultsList)
|
||||
{
|
||||
GUILayout.BeginHorizontal(_horizontalPadded);
|
||||
GUILayout.Label(s, GUILayout.Width(4 * (position.width - 4 * _horizontalPadding) / 5));
|
||||
GUI.skin.button.alignment = TextAnchor.MiddleCenter;
|
||||
if (GUILayout.Button("Select prefab", GUILayout.Width((position.width - 4 * _horizontalPadding) / 5 - 20)))
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(s);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// On GUI we draw our window's contents
|
||||
/// </summary>
|
||||
protected virtual void OnGUI()
|
||||
{
|
||||
InitializePaddingAndStyles();
|
||||
DrawTabs();
|
||||
HandleTabsChange();
|
||||
DrawSelectedTab();
|
||||
DrawResultsList();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets all prefabs and sorts them alphabetically
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] GetAllPrefabsInProject()
|
||||
{
|
||||
string[] assetPaths = AssetDatabase.GetAllAssetPaths();
|
||||
List<string> results = new List<string>();
|
||||
foreach (string assetPath in assetPaths)
|
||||
{
|
||||
if (assetPath.Contains(".prefab"))
|
||||
{
|
||||
results.Add(assetPath);
|
||||
}
|
||||
}
|
||||
results.Sort();
|
||||
return results.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6f3cc53c6ac3754bbf1b45956f64a21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A class used to add a menu item and a shortcut to group objects together under a parent game object
|
||||
/// </summary>
|
||||
public class MMGroupSelection
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a parent object and puts all selected transforms under it
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Group Selection %g")]
|
||||
public static void GroupSelection()
|
||||
{
|
||||
if (!Selection.activeTransform)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject groupObject = new GameObject();
|
||||
groupObject.name = "Group";
|
||||
|
||||
Undo.RegisterCreatedObjectUndo(groupObject, "Group Selection");
|
||||
|
||||
groupObject.transform.SetParent(Selection.activeTransform.parent, false);
|
||||
|
||||
foreach (Transform selectedTransform in Selection.transforms)
|
||||
{
|
||||
Undo.SetTransformParent(selectedTransform, groupObject.transform, "Group Selection");
|
||||
}
|
||||
Selection.activeGameObject = groupObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a908ed7f06f3bf34e8ff030a385f46f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple class that lets you lock the current inspector by pressing ctrl (or cmd) + L
|
||||
/// Pressing the same shortcut again unlocks the
|
||||
/// </summary>
|
||||
public class MMLockInspector : MonoBehaviour
|
||||
{
|
||||
[MenuItem("Tools/More Mountains/Lock Inspector %l")]
|
||||
static public void LockInspector()
|
||||
{
|
||||
Type inspectorType = typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow");
|
||||
EditorWindow inspectorWindow = EditorWindow.GetWindow(inspectorType);
|
||||
|
||||
PropertyInfo isLockedPropertyInfo = inspectorType.GetProperty("isLocked", BindingFlags.Public | BindingFlags.Instance);
|
||||
bool state = (bool)isLockedPropertyInfo.GetGetMethod().Invoke(inspectorWindow, new object[] { });
|
||||
|
||||
isLockedPropertyInfo.GetSetMethod().Invoke(inspectorWindow, new object[] { !state });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c0e71f738b287843b432d007a0626bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMMovement.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMMovement.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23f010b4ae2814c42b0ee28eaf7d5428
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for the MMAutoRotate component
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMAutoRotate), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMAutoRotateEditor : Editor
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="autoRotate"></param>
|
||||
/// <param name="gizmoType"></param>
|
||||
[DrawGizmo(GizmoType.InSelectionHierarchy)]
|
||||
static void DrawHandles(MMAutoRotate autoRotate, GizmoType gizmoType)
|
||||
{
|
||||
MMAutoRotate myTarget = autoRotate;
|
||||
|
||||
// only draw gizmos if orbiting and gizmos enabled
|
||||
if (!myTarget.Orbiting || !myTarget.DrawGizmos)
|
||||
{
|
||||
return;
|
||||
};
|
||||
|
||||
// if we're not playing, we compute our center/axis
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
if (myTarget.OrbitCenterTransform != null)
|
||||
{
|
||||
myTarget._orbitCenter = myTarget.OrbitCenterTransform.transform.position + myTarget.OrbitCenterOffset;
|
||||
myTarget._worldRotationAxis = myTarget.OrbitCenterTransform.TransformDirection(myTarget.OrbitRotationAxis);
|
||||
myTarget._rotationPlane.SetNormalAndPosition(myTarget._worldRotationAxis.normalized, myTarget._orbitCenter);
|
||||
|
||||
myTarget._snappedPosition = myTarget._rotationPlane.ClosestPointOnPlane(myTarget.transform.position);
|
||||
myTarget._radius = myTarget.OrbitRadius * Vector3.Normalize(myTarget._snappedPosition - myTarget._orbitCenter);
|
||||
}
|
||||
}
|
||||
|
||||
// draws a plane disc
|
||||
Handles.color = myTarget.OrbitPlaneColor;
|
||||
Handles.DrawSolidDisc(myTarget._orbitCenter, myTarget._rotationPlane.normal, myTarget.OrbitRadius + 0.5f);
|
||||
|
||||
// draws a circle to mark the orbit
|
||||
Handles.color = myTarget.OrbitLineColor;
|
||||
Handles.DrawWireArc(myTarget._orbitCenter, myTarget._rotationPlane.normal, Vector3.ProjectOnPlane(myTarget._orbitCenter + Vector3.forward, myTarget._rotationPlane.normal), 360f, myTarget.OrbitRadius);
|
||||
|
||||
// draws an arrow to mark the direction
|
||||
Quaternion newRotation = Quaternion.AngleAxis(1f, myTarget._worldRotationAxis);
|
||||
Vector3 origin = myTarget._orbitCenter + newRotation * myTarget._radius;
|
||||
newRotation = Quaternion.AngleAxis(15f, myTarget._worldRotationAxis);
|
||||
Vector3 direction = Vector3.zero;
|
||||
if (myTarget.OrbitRotationSpeed > 0f)
|
||||
{
|
||||
direction = (myTarget._orbitCenter + newRotation * myTarget._radius) - origin;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = origin - (myTarget._orbitCenter + newRotation * myTarget._radius);
|
||||
}
|
||||
MMDebug.DebugDrawArrow(origin, direction, myTarget.OrbitLineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b4bf5a88d386b6428629ffc983eb62c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3c387a5c035e814eb1a19b914829253
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// This class adds names for each LevelMapPathElement next to it on the scene view, for easier setup
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMPath),true)]
|
||||
[InitializeOnLoad]
|
||||
public class MMPathEditor : Editor
|
||||
{
|
||||
public MMPath pathTarget
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MMPath)target;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnSceneGUI, draws repositionable handles at every point in the path, for easier setup
|
||||
/// </summary>
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
Handles.color=Color.green;
|
||||
MMPath t = (target as MMPath);
|
||||
|
||||
if (t.GetOriginalTransformPositionStatus() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0;i<t.PathElements.Count;i++)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Vector3 oldPoint = t.GetOriginalTransformPosition()+t.PathElements[i].PathElementPosition;
|
||||
GUIStyle style = new GUIStyle();
|
||||
|
||||
// draws the path item number
|
||||
style.normal.textColor = Color.yellow;
|
||||
Handles.Label(t.GetOriginalTransformPosition()+t.PathElements[i].PathElementPosition+(Vector3.down*0.4f)+(Vector3.right*0.4f), ""+i,style);
|
||||
|
||||
// draws a movable handle
|
||||
var fmh_49_57_638478220619113249 = Quaternion.identity; Vector3 newPoint = Handles.FreeMoveHandle(oldPoint,.5f,new Vector3(.25f,.25f,.25f),Handles.CircleHandleCap);
|
||||
newPoint = ApplyAxisLock(oldPoint, newPoint);
|
||||
|
||||
// records changes
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(target, "Free Move Handle");
|
||||
t.PathElements[i].PathElementPosition = newPoint - t.GetOriginalTransformPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks handles movement on x, y, or z axis
|
||||
/// </summary>
|
||||
/// <param name="oldPoint"></param>
|
||||
/// <param name="newPoint"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual Vector3 ApplyAxisLock(Vector3 oldPoint, Vector3 newPoint)
|
||||
{
|
||||
MMPath t = (target as MMPath);
|
||||
if (t.LockHandlesOnXAxis)
|
||||
{
|
||||
newPoint.x = oldPoint.x;
|
||||
}
|
||||
if (t.LockHandlesOnYAxis)
|
||||
{
|
||||
newPoint.y = oldPoint.y;
|
||||
}
|
||||
if (t.LockHandlesOnZAxis)
|
||||
{
|
||||
newPoint.z = oldPoint.z;
|
||||
}
|
||||
|
||||
return newPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d103290728e03b448829fc4b58e285ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// This class adds names for each LevelMapPathElement next to it on the scene view, for easier setup
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMPathMovement),true)]
|
||||
[InitializeOnLoad]
|
||||
public class MMPathMovementEditor : Editor
|
||||
{
|
||||
public MMPathMovement pathMovementTarget
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MMPathMovement)target;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update ();
|
||||
|
||||
if (pathMovementTarget.AccelerationType == MMPathMovement.PossibleAccelerationType.AnimationCurve)
|
||||
{
|
||||
DrawDefaultInspector ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Editor.DrawPropertiesExcluding (serializedObject, new string [] { "Acceleration" });
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnSceneGUI, draws repositionable handles at every point in the path, for easier setup
|
||||
/// </summary>
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
Handles.color = Color.green;
|
||||
MMPathMovement t = (target as MMPathMovement);
|
||||
|
||||
if (t.GetOriginalTransformPositionStatus() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0;i<t.PathElements.Count;i++)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Vector3 oldPoint = t.PointPosition(i);
|
||||
GUIStyle style = new GUIStyle();
|
||||
|
||||
// draws the path item number
|
||||
style.normal.textColor = Color.yellow;
|
||||
Handles.Label(t.PointPosition(i) + (Vector3.down*0.4f) + (Vector3.right*0.4f), ""+i,style);
|
||||
|
||||
// draws a movable handle
|
||||
var fmh_65_57_638478220619113409 = Quaternion.identity; Vector3 newPoint = Handles.FreeMoveHandle(oldPoint,.5f,new Vector3(.25f,.25f,.25f),Handles.CircleHandleCap);
|
||||
|
||||
// records changes
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(target, "Free Move Handle");
|
||||
t.PathElements[i].PathElementPosition = newPoint - t.GetOriginalTransformPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80063623289ee3e49b584d00f3a90a32
|
||||
timeCreated: 1523894192
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMParticles.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMParticles.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3bceac71c8f2d64196c4fa6c935b200
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CanEditMultipleObjects()]
|
||||
[CustomEditor(typeof(MMRendererSortingLayer), true)]
|
||||
public class MMRendererLayerEditor : Editor
|
||||
{
|
||||
int popupMenuIndex;
|
||||
string[] sortingLayerNames;
|
||||
protected MMRendererSortingLayer _mmRendererSortingLayer;
|
||||
protected Renderer _renderer;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
sortingLayerNames = GetSortingLayerNames();
|
||||
_mmRendererSortingLayer = (MMRendererSortingLayer)target;
|
||||
_renderer = _mmRendererSortingLayer.GetComponent<Renderer> ();
|
||||
|
||||
for (int i = 0; i<sortingLayerNames.Length;i++) //here we initialize our popupMenuIndex with the current Sort Layer Name
|
||||
{
|
||||
if (sortingLayerNames[i] == _renderer.sortingLayerName)
|
||||
popupMenuIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
if (_renderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
popupMenuIndex = EditorGUILayout.Popup("Sorting Layer", popupMenuIndex, sortingLayerNames);
|
||||
int newSortingLayerOrder = EditorGUILayout.IntField("Order in Layer", _renderer.sortingOrder);
|
||||
|
||||
if (sortingLayerNames[popupMenuIndex] != _renderer.sortingLayerName
|
||||
|| newSortingLayerOrder != _renderer.sortingOrder)
|
||||
{
|
||||
Undo.RecordObject(_renderer, "Change Particle System Renderer Order");
|
||||
|
||||
_renderer.sortingLayerName = sortingLayerNames[popupMenuIndex];
|
||||
_renderer.sortingOrder = newSortingLayerOrder;
|
||||
|
||||
EditorUtility.SetDirty(_renderer);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetSortingLayerNames()
|
||||
{
|
||||
Type internalEditorUtilityType = typeof(InternalEditorUtility);
|
||||
PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
return (string[])sortingLayersProperty.GetValue(null, new object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ca3ff8bc8827e24ab1490c416d7839f
|
||||
timeCreated: 1491156263
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CanEditMultipleObjects()]
|
||||
[CustomEditor(typeof(MMTrailRendererSortingLayer), true)]
|
||||
public class MMTrailRendererLayerEditor : Editor
|
||||
{
|
||||
int popupMenuIndex;
|
||||
string[] sortingLayerNames;
|
||||
protected MMTrailRendererSortingLayer _mmTrailRendererSortingLayer;
|
||||
protected TrailRenderer _trailRenderer;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
sortingLayerNames = GetSortingLayerNames();
|
||||
_mmTrailRendererSortingLayer = (MMTrailRendererSortingLayer)target;
|
||||
_trailRenderer = _mmTrailRendererSortingLayer.GetComponent<TrailRenderer> ();
|
||||
|
||||
for (int i = 0; i<sortingLayerNames.Length;i++) //here we initialize our popupMenuIndex with the current Sort Layer Name
|
||||
{
|
||||
if (sortingLayerNames[i] == _trailRenderer.sortingLayerName)
|
||||
popupMenuIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
if (_trailRenderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
popupMenuIndex = EditorGUILayout.Popup("Sorting Layer", popupMenuIndex, sortingLayerNames);
|
||||
int newSortingLayerOrder = EditorGUILayout.IntField("Order in Layer", _trailRenderer.sortingOrder);
|
||||
|
||||
if (sortingLayerNames[popupMenuIndex] != _trailRenderer.sortingLayerName
|
||||
|| newSortingLayerOrder != _trailRenderer.sortingOrder)
|
||||
{
|
||||
Undo.RecordObject(_trailRenderer, "Change Particle System Renderer Order");
|
||||
|
||||
_trailRenderer.sortingLayerName = sortingLayerNames[popupMenuIndex];
|
||||
_trailRenderer.sortingOrder = newSortingLayerOrder;
|
||||
|
||||
EditorUtility.SetDirty(_trailRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetSortingLayerNames()
|
||||
{
|
||||
Type internalEditorUtilityType = typeof(InternalEditorUtility);
|
||||
PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
return (string[])sortingLayersProperty.GetValue(null, new object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f767333d7f0eaf24892e4778169d0d37
|
||||
timeCreated: 1491156263
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMProcedural.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMProcedural.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f89e66673b2eb9a448717d973b2e22a6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for the MMTilemapGenerator, handles generate button and reorderable layers
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMTilemapGenerator), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMTilemapGeneratorEditor : Editor
|
||||
{
|
||||
|
||||
protected MMReorderableList _list;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_list = new MMReorderableList(serializedObject.FindProperty("Layers"));
|
||||
_list.elementNameProperty = "Layer";
|
||||
_list.elementDisplayType = MMReorderableList.ElementDisplayType.Expandable;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
DrawPropertiesExcluding(serializedObject, "Layers");
|
||||
EditorGUILayout.Space(10);
|
||||
_list.DoLayoutList();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if (GUILayout.Button("Generate"))
|
||||
{
|
||||
(target as MMTilemapGenerator).Generate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fad23a01f1d6df49be8215ff24dbe62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMUtilities.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMUtilities.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f665c4f93c9d0b14580bb7f5969a3068
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// An editor class used to display menu items
|
||||
/// </summary>
|
||||
public class MMDebugEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a menu item to enable debug logs
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Enable Debug Logs", false, 100)]
|
||||
private static void EnableDebugLogs()
|
||||
{
|
||||
MMDebug.SetDebugLogsEnabled(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conditional method to determine if the "enable debug log" entry should be greyed or not
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Enable Debug Logs", true)]
|
||||
private static bool EnableDebugLogsValidation()
|
||||
{
|
||||
return !MMDebug.DebugLogsEnabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item to disable debug logs
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Disable Debug Logs", false, 101)]
|
||||
private static void DisableDebugLogs()
|
||||
{
|
||||
MMDebug.SetDebugLogsEnabled(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conditional method to determine if the "disable debug log" entry should be greyed or not
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Disable Debug Logs", true)]
|
||||
private static bool DisableDebugLogsValidation()
|
||||
{
|
||||
return MMDebug.DebugLogsEnabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item to enable debug logs
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/Enable Debug Draws", false, 102)]
|
||||
private static void EnableDebugDraws()
|
||||
{
|
||||
MMDebug.SetDebugDrawEnabled(true);
|
||||
}
|
||||
|
||||
[MenuItem("Tools/More Mountains/Enable Debug Draws", true)]
|
||||
/// <summary>
|
||||
/// Conditional method to determine if the "enable debug log" entry should be greyed or not
|
||||
/// </summary>
|
||||
private static bool EnableDebugDrawsValidation()
|
||||
{
|
||||
return !MMDebug.DebugDrawEnabled;
|
||||
}
|
||||
|
||||
[MenuItem("Tools/More Mountains/Disable Debug Draws", false, 103)]
|
||||
/// <summary>
|
||||
/// Adds a menu item to disable debug logs
|
||||
/// </summary>
|
||||
private static void DisableDebugDraws()
|
||||
{
|
||||
MMDebug.SetDebugDrawEnabled(false);
|
||||
}
|
||||
|
||||
[MenuItem("Tools/More Mountains/Disable Debug Draws", true)]
|
||||
/// <summary>
|
||||
/// Conditional method to determine if the "disable debug log" entry should be greyed or not
|
||||
/// </summary>
|
||||
private static bool DisableDebugDrawsValidation()
|
||||
{
|
||||
return MMDebug.DebugDrawEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75f9cc4cf2ef4324d99f4dc9d5709b63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(MMLayer))]
|
||||
public class MMLayerPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUI.BeginProperty(position, GUIContent.none, property);
|
||||
SerializedProperty layerIndex = property.FindPropertyRelative("_layerIndex");
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
if (layerIndex != null)
|
||||
{
|
||||
layerIndex.intValue = EditorGUI.LayerField(position, layerIndex.intValue);
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d8d3d62d1a2e8f429db2998bbdeb237
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CustomEditor(typeof(MMAspectRatioSafeZones), true)]
|
||||
public class MMScreenshotEditor : Editor
|
||||
{
|
||||
static string FolderName = "Screenshots";
|
||||
|
||||
[MenuItem("Tools/More Mountains/Screenshot/Take Screenshot Real Size", false, 801)]
|
||||
public static void MenuScreenshotSize1()
|
||||
{
|
||||
string savePath = TakeScreenCaptureScreenshot(1);
|
||||
}
|
||||
[MenuItem("Tools/More Mountains/Screenshot/Take Screenshot Size x2", false, 802)]
|
||||
public static void MenuScreenshotSize2()
|
||||
{
|
||||
string savePath = TakeScreenCaptureScreenshot(2);
|
||||
}
|
||||
[MenuItem("Tools/More Mountains/Screenshot/Take Screenshot Size x3 %k", false, 803)]
|
||||
public static void MenuScreenshotSize3()
|
||||
{
|
||||
string savePath = TakeScreenCaptureScreenshot(3);
|
||||
}
|
||||
|
||||
protected static string TakeScreenCaptureScreenshot(int gameViewSizeMultiplier)
|
||||
{
|
||||
if (!Directory.Exists(FolderName))
|
||||
{
|
||||
Directory.CreateDirectory(FolderName);
|
||||
}
|
||||
|
||||
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);
|
||||
MMDebug.DebugLogInfo("[MMScreenshot] Screenshot taken with size multiplier of " + gameViewSizeMultiplier + " and saved at " + savePath);
|
||||
return savePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82c6a6e2f2e591a498214d03f76d9f09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for the MMTransformRandomizer class
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMTransformRandomizer), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMTransformRandomizerEditor : Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// On inspector we handle undo and display a test button
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
Undo.RecordObject(target, "Modified MMTransformRandomizer");
|
||||
DrawDefaultInspector();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Test", EditorStyles.boldLabel);
|
||||
|
||||
if (GUILayout.Button("Randomize"))
|
||||
{
|
||||
foreach (MMTransformRandomizer randomizer in targets)
|
||||
{
|
||||
randomizer.Randomize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dbf82cbd8a266041acbda8137fc5b9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// This class adds names for each LevelMapPathElement next to it on the scene view, for easier setup
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMSceneViewIcon))]
|
||||
[InitializeOnLoad]
|
||||
public class SceneViewIconEditor : Editor
|
||||
{
|
||||
//protected SceneViewIcon _sceneViewIcon;
|
||||
|
||||
[DrawGizmo(GizmoType.InSelectionHierarchy | GizmoType.NotInSelectionHierarchy)]
|
||||
static void DrawGameObjectName(MMSceneViewIcon sceneViewIcon, GizmoType gizmoType)
|
||||
{
|
||||
GUIStyle style = new GUIStyle();
|
||||
style.normal.textColor = Color.blue;
|
||||
Handles.Label(sceneViewIcon.transform.position, sceneViewIcon.gameObject.name,style);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22acaeb1b9f9e4fbbb6486133e649e67
|
||||
timeCreated: 1456229446
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Feel/MMTools/Accessories/Editor/MMVision.meta
Normal file
8
Assets/Feel/MMTools/Accessories/Editor/MMVision.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 709786e9e9b9ad840b4edd10a1363bab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using MoreMountains.Tools;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CustomEditor(typeof(MMConeOfVision2D), true)]
|
||||
public class MMConeOfVision2DInspector : Editor
|
||||
{
|
||||
protected MMConeOfVision2D _coneOfVision;
|
||||
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
// draws a circle around the character to represent the cone of vision's radius
|
||||
_coneOfVision = (MMConeOfVision2D)target;
|
||||
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawWireArc(_coneOfVision.transform.position, -Vector3.forward, Vector3.up, 360f, _coneOfVision.VisionRadius);
|
||||
|
||||
// draws two lines to mark the vision angle
|
||||
Vector3 visionAngleLeft = MMMaths.DirectionFromAngle2D(-_coneOfVision.VisionAngle / 2f, _coneOfVision.EulerAngles.y);
|
||||
Vector3 visionAngleRight = MMMaths.DirectionFromAngle2D(_coneOfVision.VisionAngle / 2f, _coneOfVision.EulerAngles.y);
|
||||
|
||||
Handles.DrawLine(_coneOfVision.transform.position, _coneOfVision.transform.position + visionAngleLeft * _coneOfVision.VisionRadius);
|
||||
Handles.DrawLine(_coneOfVision.transform.position, _coneOfVision.transform.position + visionAngleRight * _coneOfVision.VisionRadius);
|
||||
|
||||
foreach (Transform visibleTarget in _coneOfVision.VisibleTargets)
|
||||
{
|
||||
Handles.color = MMColors.Orange;
|
||||
Handles.DrawLine(_coneOfVision.transform.position, visibleTarget.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b5d530aed12d5f41b876b1237c161a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using MoreMountains.Tools;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
[CustomEditor(typeof(MMConeOfVision), true)]
|
||||
public class MMConeOfVisionInspector : Editor
|
||||
{
|
||||
protected MMConeOfVision _coneOfVision;
|
||||
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
// draws a circle around the character to represent the cone of vision's radius
|
||||
_coneOfVision = (MMConeOfVision)target;
|
||||
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawWireArc(_coneOfVision.Center, Vector3.up, Vector3.forward, 360f, _coneOfVision.VisionRadius);
|
||||
|
||||
// draws two lines to mark the vision angle
|
||||
Vector3 visionAngleLeft = MMMaths.DirectionFromAngle(-_coneOfVision.VisionAngle / 2f, _coneOfVision.EulerAngles.y);
|
||||
Vector3 visionAngleRight = MMMaths.DirectionFromAngle(_coneOfVision.VisionAngle / 2f, _coneOfVision.EulerAngles.y);
|
||||
|
||||
Handles.DrawLine(_coneOfVision.Center, _coneOfVision.Center + visionAngleLeft * _coneOfVision.VisionRadius);
|
||||
Handles.DrawLine(_coneOfVision.Center, _coneOfVision.Center + visionAngleRight * _coneOfVision.VisionRadius);
|
||||
|
||||
foreach (Transform visibleTarget in _coneOfVision.VisibleTargets)
|
||||
{
|
||||
Handles.color = MMColors.Orange;
|
||||
Handles.DrawLine(_coneOfVision.Center, visibleTarget.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 887e928caeb50c74593acce11770f85f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reference": "GUID:d9dbf313afb206f458581847ac758375"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4ca86eeefb9e704a9e99ebb71e8345d
|
||||
AssemblyDefinitionReferenceImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user