修改了一些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

@@ -37,6 +37,11 @@ MonoBehaviour:
- Dreamteck.Splines
- Dreamteck.Utilities
- EasySave3
- glTFast
- glTFast.Documentation.Examples
- glTFast.dots
- glTFast.Export
- glTFast.Newtonsoft
- LeanCommon
- LeanGUI
- LeanTransition

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)
{

View File

@@ -34,7 +34,7 @@ namespace Convention
{
colorKeys = new GradientColorKey[]
{
new GradientColorKey(Color.white, 1),
new GradientColorKey(Color.white, 0),
new GradientColorKey(Color.white, 1)
}
};

View File

@@ -8,27 +8,51 @@ namespace Convention.WindowsUI.Variant
{
[Setting, Range(0, 1), Percentage(0, 1)] public float Speed = 0.36f;
[Resources, OnlyNotNullMode] public RectTransform RectBox;
[Resources, OnlyNotNullMode] public RectTransform RopParent;
[Resources, OnlyNotNullMode] public RectTransform TopParent;
[Resources] public List<RectTransform> Targets = new();
[Content] public int TargetIndex;
[Content, OnlyPlayMode] public RectTransform Target;
public RectTransform Target { get; private set; }
private Stack<ConventionUtility.ActionStepCoroutineWrapper> Tasks = new();
public void SetTargetRectTransform(RectTransform target)
{
Target = target;
if (target == null)
{
Target = null;
RectTransformInfo.UpdateAnimationPlane(TopParent, RectBox, Speed, 0, true);
}
else
{
ConventionUtility.ActionStepCoroutineWrapper task = ConventionUtility.CreateSteps();
task.Next(() =>
{
if (gameObject.activeInHierarchy == false)
RectTransformInfo.UpdateAnimationPlane(TopParent, RectBox, 1, 0, true);
})
.Until(() => target.gameObject.activeInHierarchy == true && Tasks.Peek() == task, () => Target = target)
.Next(() => Tasks.TryPop(out var _))
.Invoke();
Tasks.Push(task);
}
}
public void SelectNextTarget()
{
Debug.Log(TargetIndex);
Target = Targets[TargetIndex = (TargetIndex + 1) % Targets.Count];
}
private void Start()
{
if (TopParent == null)
TopParent = transform.parent as RectTransform;
}
private void LateUpdate()
{
if (Target != null)
RectTransformInfo.UpdateAnimationPlane(Target, RectBox, Speed, 0, true);
else
RectTransformInfo.UpdateAnimationPlane(RopParent, RectBox, Speed, 0, true);
RectTransformInfo.UpdateAnimationPlane(TopParent, RectBox, Speed, 0, true);
}
}
}

View File

@@ -125,6 +125,25 @@ namespace Convention.WindowsUI.Variant
});
}
}
public void MakeFocusOn(HierarchyItem target)
{
static void BFS(HierarchyItem t)
{
var next = t.Entry.GetParent();
if (next != null)
{
BFS(next.GetHierarchyItem());
next.GetHierarchyItem().IsFold = false;
}
}
BFS(target);
if (FocusWindowIndictaor.instance != null)
{
FocusWindowIndictaor.instance.SetTargetRectTransform(target.TextRectTransform);
}
}
}
}

View File

@@ -91,7 +91,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
Speed: 0.32
RectBox: {fileID: 6272003121708756342}
RopParent: {fileID: 8773560469810817739}
TopParent: {fileID: 0}
Targets:
- {fileID: 0}
- {fileID: 7709311530016948315}
@@ -100,7 +100,6 @@ MonoBehaviour:
- {fileID: 2403051311178796671}
- {fileID: 5377214671440830306}
TargetIndex: 0
Target: {fileID: 0}
--- !u!114 &7462675906960032546
MonoBehaviour:
m_ObjectHideFlags: 0