Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

66 行
2.0 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
namespace GameplayIngredients.Editor
{
public class CallableFlowEditorWindow : EditorWindow
{
CallableFlow m_CallableFlow;
void OnEnable()
{
titleContent = new GUIContent("Callable Flow");
Selection.selectionChanged += OnSelectionChanged;
}
private void OnDisable()
{
Selection.selectionChanged -= OnSelectionChanged;
}
private void OnSelectionChanged()
{
CallableFlow flow;
if (Selection.activeObject != null && Selection.activeGameObject.TryGetComponent<CallableFlow>(out flow))
{
OpenCallableFlow(flow);
}
}
public void OpenCallableFlow(CallableFlow flow)
{
m_CallableFlow = flow;
Repaint();
}
private void OnGUI()
{
if(m_CallableFlow == null)
{
using(new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
using(new GUILayout.VerticalScope(GUILayout.Width(320)))
{
GUILayout.FlexibleSpace();
EditorGUILayout.HelpBox("No Object selected with Callable Flow, please select an object with a callable flow component.", MessageType.Info);
GUILayout.FlexibleSpace();
}
GUILayout.FlexibleSpace();
}
return;
}
using(new GUILayout.HorizontalScope(EditorStyles.toolbar))
{
GUILayout.Button("Refresh", EditorStyles.toolbarButton);
GUILayout.FlexibleSpace();
if (GUILayout.Button(m_CallableFlow.gameObject.name, EditorStyles.toolbarButton))
EditorGUIUtility.PingObject(m_CallableFlow.gameObject);
}
}
}
}