您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
52 行
1.7 KiB
52 行
1.7 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
[CustomPropertyDrawer(typeof(BoneReferenceAuthoring))]
|
|
public class BoneReferenceAuthoringDrawer : PropertyDrawer
|
|
{
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
{
|
|
// if (prop.isExpanded)
|
|
// return 3 * EditorGUIUtility.singleLineHeight;
|
|
|
|
// return EditorGUI.GetPropertyHeight(prop);
|
|
|
|
return 2 * EditorGUIUtility.singleLineHeight;
|
|
}
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
{
|
|
|
|
|
|
// EditorGUI.BeginProperty(pos, label, prop);
|
|
|
|
|
|
// var indent = EditorGUI.indentLevel;
|
|
// EditorGUI.indentLevel = 0;
|
|
//
|
|
// var labelWidth = EditorGUIUtility.labelWidth;
|
|
// EditorGUIUtility.labelWidth = 30;
|
|
|
|
// prop.isExpanded = EditorGUI.Foldout(pos, prop.isExpanded, label);
|
|
// if (prop.isExpanded)
|
|
{
|
|
// var rigPropWidth = pos.width/2;
|
|
var rigRect = new Rect(pos.x, pos.y /*+ EditorGUIUtility.singleLineHeight*/, pos.width, EditorGUIUtility.singleLineHeight);
|
|
var rigLabel = new GUIContent("Rig");
|
|
EditorGUI.PropertyField(rigRect,prop.FindPropertyRelative("RigAsset"),rigLabel);
|
|
|
|
var boneRect = new Rect(pos.x, pos.y + EditorGUIUtility.singleLineHeight*1, pos.width , EditorGUIUtility.singleLineHeight);
|
|
var boneLabel = new GUIContent("Bone");
|
|
EditorGUI.PropertyField(boneRect,prop.FindPropertyRelative("BoneName"), boneLabel);
|
|
|
|
}
|
|
|
|
|
|
// EditorGUI.indentLevel = indent;
|
|
// EditorGUIUtility.labelWidth = labelWidth;
|
|
|
|
// EditorGUI.EndProperty();
|
|
}
|
|
}
|