63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace Gameplay.FakeFight
|
|
{
|
|
public class FakeFightManager
|
|
{
|
|
|
|
private static FakeFightManager _instance;
|
|
public static FakeFightManager instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
_instance = new FakeFightManager();
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
private const string PrefabPath = "Assets/Editor/SkillEditor/Res/技能编辑器.prefab";
|
|
|
|
private FakeFightManager()
|
|
{
|
|
}
|
|
|
|
public void Init(int skillId, int timelineId)
|
|
{
|
|
#if UNITY_EDITOR
|
|
// 切换到指定场景
|
|
UnityEditor.SceneManagement.EditorSceneManager.OpenScene("Assets/Scenes/FakeFight.unity");
|
|
|
|
// 优先进行场景内检查
|
|
var cmp = Object.FindObjectOfType<CmpFakeFightScene>();
|
|
if (cmp != null)
|
|
{
|
|
cmp.ForceInit(skillId, timelineId);
|
|
}
|
|
else
|
|
{
|
|
// 加载技能编辑器
|
|
var prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(PrefabPath);
|
|
var instObj = Object.Instantiate(prefab);
|
|
var currentScene = SceneManager.GetActiveScene();
|
|
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(currentScene);
|
|
|
|
// 关联技能id和timelineid
|
|
cmp = instObj.GetComponent<CmpFakeFightScene>();
|
|
|
|
cmp.ForceInit(skillId, timelineId);
|
|
|
|
}
|
|
|
|
// 打开timeline面板
|
|
UnityEditor.EditorApplication.ExecuteMenuItem("Window/Sequencing/Timeline");
|
|
#endif
|
|
}
|
|
|
|
}
|
|
}
|