修改了一些bug,并补充了一些函数

This commit is contained in:
2025-09-21 17:33:31 +08:00
parent f8aea1c383
commit ce56cca782
8 changed files with 114 additions and 19 deletions

View File

@@ -1,6 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using Convention.WindowsUI.Variant;
using UnityEngine;
using UnityEngine.InputSystem;
@@ -29,6 +26,16 @@ namespace Convention
}
}
public void SetMoveSpeed(float value)
{
moveSpeed = value;
}
public void SetRotationSpeed(float value)
{
rotationSpeed = value;
}
private void Start()
{
m_IsFocus = false;

View File

@@ -1064,33 +1064,62 @@ namespace Convention
public class ActionStepCoroutineWrapper
{
private List<KeyValuePair<YieldInstruction, Action>> steps = new();
private class YieldInstructionWrapper
{
public YieldInstruction UnityYieldInstruction;
public CustomYieldInstruction CustomYieldInstruction;
public YieldInstructionWrapper()
{
}
public YieldInstructionWrapper(YieldInstruction unityYieldInstruction)
{
this.UnityYieldInstruction = unityYieldInstruction;
}
public YieldInstructionWrapper(CustomYieldInstruction customYieldInstruction)
{
this.CustomYieldInstruction = customYieldInstruction;
}
}
private List<KeyValuePair<YieldInstructionWrapper, Action>> steps = new();
public ActionStepCoroutineWrapper Update(Action action)
{
steps.Add(new(null, action));
steps.Add(new(new(), action));
return this;
}
public ActionStepCoroutineWrapper Wait(float time, Action action)
{
steps.Add(new(new WaitForSeconds(time), action));
steps.Add(new(new(new WaitForSeconds(time)), action));
return this;
}
public ActionStepCoroutineWrapper FixedUpdate(Action action)
{
steps.Add(new(new WaitForFixedUpdate(), action));
steps.Add(new(new (new WaitForFixedUpdate()), action));
return this;
}
public ActionStepCoroutineWrapper Next(Action action)
{
steps.Add(new(new WaitForEndOfFrame(), action));
steps.Add(new(new(new WaitForEndOfFrame()), action));
return this;
}
private static IEnumerator Execute(List<KeyValuePair<YieldInstruction, Action>> steps)
public ActionStepCoroutineWrapper Until(Func<bool> pr, Action action)
{
steps.Add(new(new(new WaitUntil(pr)), action));
return this;
}
private static IEnumerator Execute(List<KeyValuePair<YieldInstructionWrapper, Action>> steps)
{
foreach (var (waiting, action) in steps)
{
action();
yield return waiting;
if (waiting.UnityYieldInstruction != null)
yield return waiting.UnityYieldInstruction;
else
yield return waiting.CustomYieldInstruction;
}
}
~ActionStepCoroutineWrapper()
@@ -1099,7 +1128,7 @@ namespace Convention
}
public void Invoke()
{
StartCoroutine(Execute(new List<KeyValuePair<YieldInstruction, Action>>(steps)));
StartCoroutine(Execute(new List<KeyValuePair<YieldInstructionWrapper, Action>>(steps)));
steps.Clear();
}
}

View File

@@ -283,6 +283,18 @@ namespace Convention
callback(result.assetBundle);
yield return null;
}
public IEnumerator LoadAsAssetBundle([In]Action<float> progress, [In] Action<AssetBundle> callback)
{
AssetBundleCreateRequest result = AssetBundle.LoadFromFileAsync(FullPath);
while (result.isDone == false)
{
progress(result.progress);
yield return null;
}
yield return result;
callback(result.assetBundle);
yield return null;
}
public string LoadAsUnknown(string suffix)
{