modify
This commit is contained in:
parent
11e5744b46
commit
44b8b3a216
@ -1,43 +1,58 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.AnimationFlow.Editor {
|
namespace AlicizaX.AnimationFlow.Editor
|
||||||
public static class EditorResourceTool {
|
{
|
||||||
|
public static class EditorResourceTool
|
||||||
|
{
|
||||||
public static string editorAssets;
|
public static string editorAssets;
|
||||||
|
|
||||||
public static bool LocateEditorAssets() {
|
public static bool LocateEditorAssets()
|
||||||
|
{
|
||||||
string projectPath = Application.dataPath;
|
string projectPath = Application.dataPath;
|
||||||
if (projectPath.EndsWith("/Assets")) {
|
if (projectPath.EndsWith("/Assets"))
|
||||||
|
{
|
||||||
projectPath = projectPath.Remove(projectPath.Length - ("Assets".Length));
|
projectPath = projectPath.Remove(projectPath.Length - ("Assets".Length));
|
||||||
}
|
}
|
||||||
editorAssets = "Packages/com.yuliuren.alicizaframework/ThirdParty/AnimationFlow/Editor/Styles";
|
|
||||||
if (!System.IO.File.Exists(projectPath + editorAssets + "/AnimationFlowStyles.uss")) {
|
editorAssets = "Packages/com.alicizax.unity.animationflow/Editor/Styles";
|
||||||
|
if (!System.IO.File.Exists(projectPath + editorAssets + "/AnimationFlowStyles.uss"))
|
||||||
|
{
|
||||||
var sdir = new System.IO.DirectoryInfo(Application.dataPath);
|
var sdir = new System.IO.DirectoryInfo(Application.dataPath);
|
||||||
var dirQueue = new Queue<System.IO.DirectoryInfo>();
|
var dirQueue = new Queue<System.IO.DirectoryInfo>();
|
||||||
dirQueue.Enqueue(sdir);
|
dirQueue.Enqueue(sdir);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
while (dirQueue.Count > 0) {
|
while (dirQueue.Count > 0)
|
||||||
|
{
|
||||||
System.IO.DirectoryInfo dir = dirQueue.Dequeue();
|
System.IO.DirectoryInfo dir = dirQueue.Dequeue();
|
||||||
if (System.IO.File.Exists(dir.FullName + "/AnimationFlowStyles.uss")) {
|
if (System.IO.File.Exists(dir.FullName + "/AnimationFlowStyles.uss"))
|
||||||
|
{
|
||||||
string path = dir.FullName.Replace('\\', '/');
|
string path = dir.FullName.Replace('\\', '/');
|
||||||
found = true;
|
found = true;
|
||||||
path = path.Replace(projectPath, "");
|
path = path.Replace(projectPath, "");
|
||||||
if (path.StartsWith("/")) {
|
if (path.StartsWith("/"))
|
||||||
|
{
|
||||||
path = path.Remove(0, 1);
|
path = path.Remove(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
editorAssets = path;
|
editorAssets = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dirs = dir.GetDirectories();
|
var dirs = dir.GetDirectories();
|
||||||
for (int i = 0; i < dirs.Length; i++) {
|
for (int i = 0; i < dirs.Length; i++)
|
||||||
|
{
|
||||||
dirQueue.Enqueue(dirs[i]);
|
dirQueue.Enqueue(dirs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
Debug.LogWarning("Could not locate editor assets folder. Make sure you have imported the package correctly.");
|
Debug.LogWarning("Could not locate editor assets folder. Make sure you have imported the package correctly.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "AlicizaX.AnimationFlow.Runtime",
|
"name": "AlicizaX.AnimationFlow.Runtime",
|
||||||
"rootNamespace": "AlicizaX.AnimationFlow.Runtime",
|
"rootNamespace": "AlicizaX.AnimationFlow.Runtime",
|
||||||
"references": [],
|
"references": [
|
||||||
|
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||||
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": false,
|
||||||
|
@ -2,17 +2,19 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.AnimationFlow.Runtime
|
namespace AlicizaX.AnimationFlow.Runtime
|
||||||
{
|
{
|
||||||
|
[DisallowMultipleComponent]
|
||||||
public class AnimationFlow : MonoBehaviour
|
public class AnimationFlow : MonoBehaviour
|
||||||
{
|
{
|
||||||
#region Editor相关
|
#region Editor相关
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
IEnumerable GetAllAnimationClips
|
public List<string> GetAllAnimationClips
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -33,7 +35,7 @@ namespace AlicizaX.AnimationFlow.Runtime
|
|||||||
[Button("节点编辑器", ButtonSizes.Large), GUIColor(0, 1, 0)]
|
[Button("节点编辑器", ButtonSizes.Large), GUIColor(0, 1, 0)]
|
||||||
private void OpenGraphWindow()
|
private void OpenGraphWindow()
|
||||||
{
|
{
|
||||||
UnityEditor.EditorApplication.ExecuteMenuItem("AlicizaFramework/Window/AnimationGraph");
|
UnityEditor.EditorApplication.ExecuteMenuItem("Window/AnimationGraph");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -223,14 +225,19 @@ namespace AlicizaX.AnimationFlow.Runtime
|
|||||||
_resetNodes.Add(node);
|
_resetNodes.Add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UniTask PlayAsync(string clipName)
|
||||||
|
{
|
||||||
|
|
||||||
|
var tcs = new UniTaskCompletionSource();
|
||||||
|
|
||||||
|
Action asyncCallBack = () => tcs.TrySetResult();
|
||||||
|
Play(clipName, asyncCallBack);
|
||||||
|
|
||||||
|
return tcs.Task;
|
||||||
|
}
|
||||||
|
|
||||||
public void Play(string clipName = "", Action actionComplete = null)
|
public void Play(string clipName = "", Action actionComplete = null)
|
||||||
{
|
{
|
||||||
if (_playebleType == EAnimationFlowPlayebleType.Play)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"animation flow is playing!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(clipName) || clipName == "None")
|
if (string.IsNullOrEmpty(clipName) || clipName == "None")
|
||||||
{
|
{
|
||||||
@ -238,6 +245,13 @@ namespace AlicizaX.AnimationFlow.Runtime
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_playebleType == EAnimationFlowPlayebleType.Play)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"animation flow is playing!");
|
||||||
|
StopFlow(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_playFinishEvent = actionComplete;
|
_playFinishEvent = actionComplete;
|
||||||
|
|
||||||
EntryNode entryNode = AnimationNodes.Find(a => a.Name == clipName);
|
EntryNode entryNode = AnimationNodes.Find(a => a.Name == clipName);
|
||||||
|
Loading…
Reference in New Issue
Block a user