44 lines
1.3 KiB
C#

using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
namespace Passer.CreatureControl {
[CustomEditor(typeof(Creature), true)]
public class Creature_Editor : Editor {
protected Creature creature;
public virtual void OnEnable() {
creature = (Creature)target;
if (creature == null)
return;
if (!IsPrefab(creature))
InitTargets(creature);
}
public static bool IsPrefab(Creature creature) {
PrefabStage prefabStage = PrefabStageUtility.GetPrefabStage(creature.gameObject);
return prefabStage != null;
}
#region Targets
protected virtual void InitTargets(Creature creature) {
TargetsRigInspector(creature, "TargetRig");
}
protected void TargetsRigInspector(Creature creature, string targetRigResourceName) {
Creature.CheckTargetRig(creature, targetRigResourceName);
if (creature.targetRig.gameObject.hideFlags != HideFlags.None) {
creature.targetRig.gameObject.hideFlags = HideFlags.None;
EditorApplication.DirtyHierarchyWindowSorting();
}
}
}
#endregion Targets
}