You've already forked taptap2024_GJ_chidouren
72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace XFFSM
|
|
{
|
|
public class XFFSMMenu
|
|
{
|
|
[MenuItem("Assets/Create/XFKT/XFFSM/FSMController")]
|
|
static void CreateFSM() {
|
|
|
|
RuntimeFSMControllerCreator runtimeFSMControllerCreator = ScriptableObject.CreateInstance<RuntimeFSMControllerCreator>();
|
|
|
|
string fileName = GetName();
|
|
|
|
#if UNITY_2018
|
|
GUIContent content = EditorGUIUtility.IconContent("icons/processed/unityengine/billboardasset icon.asset");
|
|
#elif UNITY_2019_1_OR_NEWER
|
|
GUIContent content = EditorGUIUtility.IconContent("d_ScriptableObject Icon");
|
|
#endif
|
|
|
|
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(runtimeFSMControllerCreator.GetInstanceID(), runtimeFSMControllerCreator, fileName, (Texture2D)content.image, null);
|
|
}
|
|
|
|
internal static string GetName(string templateName = "New FSMController", string suffix = "asset") {
|
|
|
|
string name;
|
|
string[] files;
|
|
|
|
int i = 0;
|
|
|
|
do
|
|
{
|
|
name = string.Format("{0}{1}", templateName, i == 0 ? string.Empty : i.ToString());
|
|
files = AssetDatabase.FindAssets(name);
|
|
|
|
i++;
|
|
} while (files != null && files.Length != 0);
|
|
|
|
return string.Format("{0}.{1}", name, suffix);
|
|
}
|
|
|
|
[MenuItem("Window/XFKT/XFFSM/StateMachineWindow",false,4000 )]
|
|
static void StateMachineWindow()
|
|
{
|
|
FSMEditorWindow window = EditorWindow.GetWindow<FSMEditorWindow>();
|
|
window.Show();
|
|
}
|
|
|
|
[MenuItem("Assets/Create/XFKT/XFFSM/FSMState")]
|
|
static void CreateFSMState() {
|
|
FSMStateCreator stateCreator = ScriptableObject.CreateInstance<FSMStateCreator>();
|
|
|
|
string fileName = GetName("NewState", "cs");
|
|
|
|
GUIContent content = EditorGUIUtility.IconContent("icons/processed/cs script icon.asset");
|
|
|
|
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(stateCreator.GetInstanceID(), stateCreator, fileName, (Texture2D)content.image, string.Empty);
|
|
}
|
|
|
|
[MenuItem("Window/XFKT/XFFSM/About",false,5000)]
|
|
static void About()
|
|
{
|
|
//Debug.Log("About");
|
|
Rect rect = new Rect(0, 0, 550, 350);
|
|
FSMAboutWindow window = EditorWindow.GetWindowWithRect<FSMAboutWindow>(rect, true, "About XFFSM");
|
|
window.Show();
|
|
}
|
|
|
|
}
|
|
|
|
} |