107 lines
3.9 KiB
C#
107 lines
3.9 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
[CustomEditor(typeof(SoftBoneScript), true)]
|
|
public class SoftBoneScriptInspector : Editor
|
|
{
|
|
private bool DrawPart(SoftBoneScript.Particle part)
|
|
{
|
|
if (part.DstTrans == null)
|
|
return false;
|
|
var result = false;
|
|
GUILayout.BeginVertical();
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Space(10 * part.Depth);
|
|
EditorGUILayout.ObjectField(part.DstTrans.gameObject, typeof(GameObject), true);
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.BeginHorizontal();
|
|
GUILayout.Space(10 * part.Depth);
|
|
EditorGUILayout.LabelField("Factor", GUILayout.Width(70));
|
|
var newValue = EditorGUILayout.DelayedFloatField(part.Factor, GUILayout.Width(50));
|
|
if(part.Factor != newValue)
|
|
{
|
|
part.Factor = newValue;
|
|
result = true;
|
|
}
|
|
GUILayout.Space(10 * part.Depth);
|
|
EditorGUILayout.LabelField("DisMultiple", GUILayout.Width(70));
|
|
newValue = EditorGUILayout.DelayedFloatField(part.DisMultiple, GUILayout.Width(50));
|
|
if (part.DisMultiple != newValue)
|
|
{
|
|
part.DisMultiple = newValue;
|
|
result = true;
|
|
}
|
|
EditorGUILayout.LabelField("MaxRotAngle", GUILayout.Width(70));
|
|
newValue = EditorGUILayout.DelayedFloatField(part.MaxRotAngle, GUILayout.Width(50));
|
|
if (part.MaxRotAngle != newValue)
|
|
{
|
|
part.MaxRotAngle = newValue;
|
|
result = true;
|
|
}
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.EndVertical();
|
|
return result;
|
|
}
|
|
public override void OnInspectorGUI()
|
|
{
|
|
var script = serializedObject.targetObject as SoftBoneScript;
|
|
if (script == null)
|
|
return;
|
|
GUILayout.BeginVertical();
|
|
var isDirty = false;
|
|
if (script.PartList == null || script.PartList.Count <= 0)
|
|
{
|
|
if (GUILayout.Button("生成节点", GUILayout.Width(100)))
|
|
{
|
|
script.BuildParticle();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GUILayout.Button("重新生成节点", GUILayout.Width(100)))
|
|
{
|
|
script.BuildParticle();
|
|
}
|
|
}
|
|
var bValue = EditorGUILayout.Toggle("位移柔化", script.MoveExecute);
|
|
if(bValue != script.MoveExecute)
|
|
{
|
|
script.MoveExecute = bValue;
|
|
isDirty = true;
|
|
}
|
|
bValue = EditorGUILayout.Toggle("旋转柔化", script.RotExecute);
|
|
if (bValue != script.RotExecute)
|
|
{
|
|
script.RotExecute = bValue;
|
|
isDirty = true;
|
|
}
|
|
NGUIEditorTools.DrawProperty("根节点", serializedObject, "_rootTrans");
|
|
script._factorStart = NGUIEditorTools.DrawProperty("开始因子", serializedObject, "_factorStart").floatValue;
|
|
script._factorEnd = NGUIEditorTools.DrawProperty("结束因子", serializedObject, "_factorEnd").floatValue;
|
|
script._angleStart = NGUIEditorTools.DrawProperty("开始角度", serializedObject, "_angleStart").floatValue;
|
|
script._angleEnd = NGUIEditorTools.DrawProperty("结束角度", serializedObject, "_angleEnd").floatValue;
|
|
script._stopMaxTime = NGUIEditorTools.DrawProperty("结束同步时间", serializedObject, "_stopMaxTime").floatValue;
|
|
if(script.PartList != null)
|
|
{
|
|
EditorGUILayout.LabelField(string.Format("总骨骼数: {0}", script.PartList.Count));
|
|
}
|
|
|
|
if (script.PartList != null)
|
|
{
|
|
for (int i = 0; i < script.PartList.Count; ++i)
|
|
{
|
|
isDirty |= DrawPart(script.PartList[i]);
|
|
}
|
|
}
|
|
if (isDirty)
|
|
{
|
|
EditorUtility.SetDirty(script);
|
|
EditorUtility.SetDirty(script.gameObject);
|
|
}
|
|
GUILayout.EndVertical();
|
|
serializedObject.Update();
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
} |