From 63043cb4ecba98b648326abbdb50be4ff2084edc Mon Sep 17 00:00:00 2001 From: rurre Date: Fri, 22 Dec 2023 09:16:09 +0200 Subject: [PATCH] feat: Added BlendTree to right click create asset menu. (#555) * Added BlendTree to right click create asset menu. Not sure where to put it, so into the root editor folder it goes. * Update CreateBlendTree.cs * chore: add missing .meta file --------- Co-authored-by: bd_ --- Editor/CreateBlendTree.cs | 32 ++++++++++++++++++++++++++++++++ Editor/CreateBlendTree.cs.meta | 11 +++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Editor/CreateBlendTree.cs create mode 100644 Editor/CreateBlendTree.cs.meta diff --git a/Editor/CreateBlendTree.cs b/Editor/CreateBlendTree.cs new file mode 100644 index 00000000..21838f79 --- /dev/null +++ b/Editor/CreateBlendTree.cs @@ -0,0 +1,32 @@ +using System.IO; +using UnityEditor; +using UnityEditor.Animations; +using UnityEditor.ProjectWindowCallback; +using UnityEngine; + +namespace nadena.dev.modular_avatar.core.editor +{ + internal static class CreateBlendTree + { + [MenuItem("Assets/Create/BlendTree", priority = 411)] + static void CreateNewBlendTree() + { + ProjectWindowUtil.StartNameEditingIfProjectWindowExists( + 0, + Editor.CreateInstance(), + "New BlendTree.asset", + EditorGUIUtility.IconContent("BlendTree Icon").image as Texture2D, + null); + } + + class DoCreateBlendTree : EndNameEditAction + { + public override void Action(int instanceId, string pathName, string resourceFile) + { + BlendTree blendTree = new BlendTree { name = Path.GetFileNameWithoutExtension(pathName) }; + AssetDatabase.CreateAsset(blendTree, pathName); + Selection.activeObject = blendTree; + } + } + } +} diff --git a/Editor/CreateBlendTree.cs.meta b/Editor/CreateBlendTree.cs.meta new file mode 100644 index 00000000..3541c8a5 --- /dev/null +++ b/Editor/CreateBlendTree.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e608a27c3d14edf43858004513948da1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: