using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using WT_LZY;
[CustomEditor(typeof(ProcedureBase))]
[CanEditMultipleObjects]
public class ProcedureBaseEditor : Editor
{
SerializedProperty mProcedureBase;
//private SerializedObject obj;
void OnEnable()
{
mProcedureBase = serializedObject.FindProperty("ProcedureBase");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
EditorGUI.BeginChangeCheck();
ProcedureBase pobj=target as ProcedureBase;
if (GUILayout.Button("更新stepID"))
{
StepBase[] stepBases= pobj.GetComponentsInChildren<StepBase>();
foreach (StepBase _stepBase in stepBases)
{
_stepBase.StepId = _stepBase.transform.GetSiblingIndex();
string[] strs= _stepBase.gameObject.name.Split('.');
_stepBase.gameObject.name= _stepBase.StepId.ToString() + "." + strs[1];
}
Debug.Log("It's alive: " + target.name);
}
if(EditorGUI.EndChangeCheck() && !EditorUtility.IsDirty(target))
EditorUtility.SetDirty(target);
}
}
1.特点:
1.针对某个类型inspector 面板Gui 扩展