Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

108 行
3.7 KiB

using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using NaughtyAttributes.Editor;
using GameplayIngredients.Rigs;
namespace GameplayIngredients.Editor
{
[CustomEditor(typeof(Rig), true)]
public class RigEditor : PingableEditor
{
SerializedProperty m_UpdateMode;
SerializedProperty m_RigPriority;
List<SerializedProperty> rigProperties;
static GUIContent callableIcon;
protected override void OnEnable()
{
base.OnEnable();
callableIcon = new GUIContent(AssetDatabase.LoadAssetAtPath<Texture2D>("Packages/net.peeweek.gameplay-ingredients/Icons/Misc/ic-callable.png"));
m_UpdateMode = serializedObject.FindProperty("m_UpdateMode");
m_RigPriority = serializedObject.FindProperty("m_RigPriority");
if (rigProperties == null)
rigProperties = new List<SerializedProperty>();
else
rigProperties.Clear();
Type inspectedType = this.serializedObject.targetObject.GetType();
foreach(FieldInfo info in inspectedType.FindMembers(MemberTypes.Field,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, null))
{
if (info.IsNotSerialized)
continue;
var property = serializedObject.FindProperty(info.Name);
if (property != null)
rigProperties.Add(property);
}
}
public override void OnInspectorGUI_PingArea()
{
serializedObject.Update();
bool excludedRigManager = GameplayIngredientsSettings.currentSettings.excludedeManagers.Any(s => s == "RigManager");
if (excludedRigManager)
{
EditorGUILayout.HelpBox("This Rig depends on the Rig Manager which is excluded in your Gameplay Ingredients Settings. This rig component will be inactive unless the manager is not excluded.", MessageType.Error, true);
if (GUILayout.Button("Open Settings"))
Selection.activeObject = GameplayIngredientsSettings.currentSettings;
}
EditorGUI.BeginDisabledGroup(excludedRigManager);
EditorGUI.BeginChangeCheck();
GUILayout.Label("Rig : Update Properties", EditorStyles.boldLabel);
using (new GUILayout.HorizontalScope())
{
using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true)))
{
using (new EditorGUI.IndentLevelScope(1))
{
NaughtyEditorGUI.PropertyField_Layout(m_UpdateMode, true);
NaughtyEditorGUI.PropertyField_Layout(m_RigPriority, true);
}
}
GUILayout.Space(8);
if (GUILayout.Button(callableIcon, GUILayout.Width(48), GUILayout.ExpandHeight(true)))
{
// Open Debug Window
IngredientsExplorerWindow.OpenWindow(this.serializedObject.targetObject as Rig);
}
}
EditorGUILayout.Space();
GUILayout.Label("Rig Properties", EditorStyles.boldLabel);
using (new EditorGUI.IndentLevelScope(1))
{
foreach (var prop in rigProperties)
NaughtyEditorGUI.PropertyField_Layout(prop, true);
}
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
}
EditorGUI.EndDisabledGroup();
}
}
}