Open ZenithVal opened 1 year ago
In general, there is no reason for blend trees to not be exportable since you can just save them to assets like any other object.
If you open an animator in a text editor and set the m_ObjectHideFlags
to 0 on a blend tree you can see it as a sub asset and duplicate it in the editor, so should be easy to do in script.
Also, updated the BlendTree creation code to be more in line with how other assets get created.
// CreateBlendTree.cs by Pumkin
// https://github.com/rurre
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEditor.Animations;
using UnityEditor.ProjectWindowCallback;
using UnityEngine;
namespace CreateBlendTree
{
public class CreateBlendTree : Editor
{
[MenuItem("Assets/Create/BlendTree", priority = 411)]
static void CreateNewBlendTree()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
0,
CreateInstance<DoCreateBlendTree>(),
"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;
}
}
}
}
#endif
Blendtrees made in the animator cannot be utilized outside the source animator unless copy pasted. That's painful because changes will not propagate. An option to export the selected blendtree as a standalone asset would be very nice.
Asset Blendtrees available in the right click create menu might also be appreciated.
Some code @rurre assembled for specifically that a bit ago: