chore: initial commit
This commit is contained in:
@@ -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:
|
||||
Reference in New Issue
Block a user