MeshRendererでSortingLayerIDやOrderInLayerを変更する拡張スクリプト
おそらく既出でしょうけど作ってみました!
Editor フォルダに下記スクリプトをいれる
MyMeshRendererInspector.cs
using UnityEngine;
using UnityEditor;
using System.Linq;
[CustomEditor(typeof(MeshRenderer))]
public class MyMeshRendererInspector : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.BeginHorizontal();
// sorting order
SerializedProperty sortOrderProperty = serializedObject.FindProperty("m_SortingOrder");
sortOrderProperty.intValue = EditorGUILayout.IntField("Sort Order", sortOrderProperty.intValue);
// sorting layer
SerializedProperty layerIDProperty = serializedObject.FindProperty("m_SortingLayerID");
var index = System.Array.FindIndex(SortingLayer.layers, layer => layer.id == layerIDProperty.intValue);
index = EditorGUILayout.Popup(index, (from layer in SortingLayer.layers select layer.name).ToArray());
layerIDProperty.intValue = SortingLayer.layers[index].id;
EditorGUILayout.EndHorizontal();
serializedObject.ApplyModifiedProperties();
base.OnInspectorGUI();
}
}
Sorting Layer と Order in Layer が表示されるようになります。
何か問題ありましたら教えてください!
Author And Source
この問題について(MeshRendererでSortingLayerIDやOrderInLayerを変更する拡張スクリプト), 我々は、より多くの情報をここで見つけました https://qiita.com/miikun109/items/dada342d23bf58cc879f著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .