46 lines
1.1 KiB (Stored with Git LFS)
C#
46 lines
1.1 KiB (Stored with Git LFS)
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Superlazy.UI
|
|
{
|
|
[CustomEditor(typeof(SLUIResource))]
|
|
public class SLUIResourceEditor : Editor
|
|
{
|
|
private SLUIResource component;
|
|
|
|
private GameObject obj;
|
|
private Editor preview;
|
|
|
|
private void OnEnable()
|
|
{
|
|
component = target as SLUIResource;
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
base.OnInspectorGUI();
|
|
|
|
var newObj = AssetDatabase.LoadAssetAtPath<GameObject>($"Assets/Addressables/{component.effectBind}.prefab");
|
|
|
|
if (obj != newObj)
|
|
{
|
|
obj = newObj;
|
|
if (preview != null) DestroyImmediate(preview);
|
|
}
|
|
|
|
if (obj == null)
|
|
{
|
|
EditorGUILayout.HelpBox("Can't Find Prefab", MessageType.Error);
|
|
}
|
|
else
|
|
{
|
|
if (preview == null)
|
|
{
|
|
preview = Editor.CreateEditor(obj);
|
|
}
|
|
|
|
preview.OnInteractivePreviewGUI(GUILayoutUtility.GetRect(200, 200), new GUIStyle());
|
|
}
|
|
}
|
|
}
|
|
} |