Files
Studio/Assets/Scripts/Examples/AutoFactory/AGVNodeEditor.cs

36 lines
1009 B
C#

namespace Studio.EditorUtil
{
using System;
using UnityEditor;
using UnityEngine;
using Studio.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
}