Files
Studio/Assets/Scripts/AGVNodeEditor.cs
2025-05-15 09:49:17 +09:00

36 lines
1003 B
C#

namespace XED.EditorUtil
{
using System;
using UnityEditor;
using UnityEngine;
using XED.VirtualFactory;
#if UNITY_EDITOR
[CustomEditor(typeof(AGVNode))]
public class AGVNodeEditor : Editor
{
AGVNode node;
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
node = (AGVNode)target;
if (GUILayout.Button("Create New Connection Node"))
{
CreateNewConnectionNode();
}
}
private void CreateNewConnectionNode()
{
var copy = Instantiate(node);
copy.transform.position = node.transform.position + Vector3.right * 2;
copy.transform.parent = node.transform.parent;
copy.linkedNodes= new();
copy.linkedNodes.Add(node);
copy.entity = new AGVNodeEntity();
node.linkedNodes.Add(copy);
Selection.activeGameObject = copy.gameObject;
}
}
#endif
}