导入角色动画,和增加角色控制
This commit is contained in:
63
Assets/KINEMATION/MagicBlend/Editor/MagicDragAndDrop.cs
Normal file
63
Assets/KINEMATION/MagicBlend/Editor/MagicDragAndDrop.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
// Designed by KINEMATION, 2025.
|
||||
|
||||
using KINEMATION.MagicBlend.Runtime;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KINEMATION.MagicBlend.Editor
|
||||
{
|
||||
public class MagicDragAndDrop
|
||||
{
|
||||
private static DragAndDropVisualMode OnHierarchyDrop(int dropTargetInstanceID, HierarchyDropFlags dropMode,
|
||||
Transform parentForDraggedObjects, bool perform)
|
||||
{
|
||||
var asset = DragAndDrop.objectReferences[0] as MagicBlendAsset;
|
||||
if (asset == null)
|
||||
{
|
||||
return DragAndDropVisualMode.None;
|
||||
}
|
||||
|
||||
if (perform)
|
||||
{
|
||||
var selection = Selection.activeGameObject;
|
||||
if (selection != null)
|
||||
{
|
||||
var component = selection.GetComponent<MagicBlending>();
|
||||
if (component == null) component = selection.AddComponent<MagicBlending>();
|
||||
component.SetMagicBlendAsset(asset);
|
||||
}
|
||||
}
|
||||
|
||||
return DragAndDropVisualMode.Copy;
|
||||
}
|
||||
|
||||
private static DragAndDropVisualMode OnInspectorDrop(UnityEngine.Object[] targets, bool perform)
|
||||
{
|
||||
var asset = DragAndDrop.objectReferences[0] as MagicBlendAsset;
|
||||
if (asset == null)
|
||||
{
|
||||
return DragAndDropVisualMode.None;
|
||||
}
|
||||
|
||||
if (perform)
|
||||
{
|
||||
var selection = Selection.activeGameObject;
|
||||
if (selection != null)
|
||||
{
|
||||
var component = selection.GetComponent<MagicBlending>();
|
||||
if (component == null) component = selection.AddComponent<MagicBlending>();
|
||||
component.SetMagicBlendAsset(asset);
|
||||
}
|
||||
}
|
||||
|
||||
return DragAndDropVisualMode.Copy;
|
||||
}
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
private static void OnLoad()
|
||||
{
|
||||
DragAndDrop.AddDropHandler(OnInspectorDrop);
|
||||
DragAndDrop.AddDropHandler(OnHierarchyDrop);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user