You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System.Reflection;
|
|
using LanLib.UpdateManager.Jobs;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace LanLib.UpdateManager.EditorUtilities
|
|
{
|
|
[CustomEditor(typeof(AJobBehaviour<>), true)]
|
|
[CanEditMultipleObjects]
|
|
public class AJobBehaviourEditor : Editor
|
|
{
|
|
private GUIStyle TopAnchoredLabel => _topAnchoredLabel != null
|
|
? _topAnchoredLabel
|
|
: (_topAnchoredLabel = new GUIStyle(EditorStyles.label)
|
|
{
|
|
alignment = TextAnchor.UpperLeft
|
|
});
|
|
|
|
private GUIStyle _topAnchoredLabel;
|
|
|
|
public override bool HasPreviewGUI()
|
|
{
|
|
return Application.isPlaying
|
|
&& !serializedObject.isEditingMultipleObjects
|
|
&& ((MonoBehaviour)target).isActiveAndEnabled;
|
|
}
|
|
|
|
public override GUIContent GetPreviewTitle()
|
|
{
|
|
return new GUIContent($"{target.GetType().Name} Job Data");
|
|
}
|
|
|
|
public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
|
|
{
|
|
PropertyInfo prop = target.GetType().GetProperty("JobData");
|
|
GUI.Label(r, JsonUtility.ToJson(prop.GetValue(target), true), TopAnchoredLabel);
|
|
}
|
|
}
|
|
} |