修复了一些bug(包含窗口预制体中的错误与{}列表解析存在死循环的错误)

This commit is contained in:
2025-10-04 23:09:46 +08:00
parent 1ecb1b0ba4
commit 84e31fe63a
16 changed files with 2590 additions and 832 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c659abfe74df5de47a769f8d52c18fcc
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4375,6 +4375,156 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 2116336193971074294, guid: 5ce7ebb07fd13814f8c9f3f07eb0fa82, type: 3}
m_PrefabInstance: {fileID: 3655111983868541195}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &4095642801624697522
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 580099326002337602}
m_Modifications:
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_title
value: Real Play
objectReference: {fileID: 0}
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: CloseCurrentProject
objectReference: {fileID: 0}
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
value: Demo.Editor.EditorController, Assembly-CSharp
objectReference: {fileID: 0}
- target: {fileID: 79093104384552664, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: clickEvent.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 1700112587579632845, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_text
value: Real Play
objectReference: {fileID: 0}
- target: {fileID: 1700112587579632845, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_fontSize
value: 25
objectReference: {fileID: 0}
- target: {fileID: 1700112588308198876, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_text
value: Real Play
objectReference: {fileID: 0}
- target: {fileID: 1700112588308198876, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_fontSize
value: 25
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_SizeDelta.x
value: 190
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_SizeDelta.y
value: 30
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663275, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_Name
value: ModernUIButton<Real Play>
objectReference: {fileID: 0}
- target: {fileID: 1700112589223663275, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
--- !u!224 &3408844528828898328 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1700112589223663274, guid: 630e23319fe05f246a3b983540e4ebe6, type: 3}
m_PrefabInstance: {fileID: 4095642801624697522}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &5166065024014529384
PrefabInstance:
m_ObjectHideFlags: 0
@@ -4908,7 +5058,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8781068999274584588, guid: 14851ab435cb18448974bf76e92d8952, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0.0000019073486
value: -0.0000064373016
objectReference: {fileID: 0}
- target: {fileID: 9007109900202818382, guid: 14851ab435cb18448974bf76e92d8952, type: 3}
propertyPath: m_AnchorMax.y
@@ -5585,6 +5735,30 @@ PrefabInstance:
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[0].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[1].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[5].m_PersistentCalls.m_Calls.Array.data[1].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[9].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 5755241224653137510, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_ActionEvents.Array.data[12].m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
@@ -5601,6 +5775,22 @@ PrefabInstance:
propertyPath: m_Name
value: Root Variant
objectReference: {fileID: 0}
- target: {fileID: 6289761285527973436, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_BackGroundColor.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6289761285527973436, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_BackGroundColor.b
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6289761285527973436, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_BackGroundColor.g
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6289761285527973436, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_BackGroundColor.r
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6329040814936255555, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_SizeDelta.x
value: 0
@@ -5695,11 +5885,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7580279236199643999, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0.000009775162
value: 0.000010967255
objectReference: {fileID: 0}
- target: {fileID: 7580279236199643999, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.000016057013
value: 0.00000667572
objectReference: {fileID: 0}
- target: {fileID: 8045550196878911107, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_LocalPosition.z
@@ -5733,6 +5923,10 @@ PrefabInstance:
propertyPath: m_PixelsPerUnitMultiplier
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8634692786306716454, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 8669671495623211341, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_AnchorMax.x
value: 0
@@ -5741,6 +5935,10 @@ PrefabInstance:
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8817857059114646283, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 0}
- target: {fileID: 8975250389949325068, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
propertyPath: m_AnchorMax.y
value: 1
@@ -5777,6 +5975,7 @@ PrefabInstance:
- {fileID: 9221906298468010471, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
- {fileID: 125856362713075159, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
- {fileID: 2319537278398014183, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
- {fileID: 2842681098514009160, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
m_RemovedGameObjects:
- {fileID: 1856571030295694548, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
- {fileID: 6464781931800549621, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
@@ -5814,6 +6013,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 7580279236199643999, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
insertIndex: -1
addedObject: {fileID: 2219000631823875985}
- targetCorrespondingSourceObject: {fileID: 7580279236199643999, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
insertIndex: -1
addedObject: {fileID: 3408844528828898328}
- targetCorrespondingSourceObject: {fileID: 2714516855717762589, guid: 48027c3ec4553d442a59415ffb40f209, type: 3}
insertIndex: 0
addedObject: {fileID: 7147508820867495363}

View File

@@ -78,9 +78,11 @@ namespace Demo.Editor
[Content, SerializeField] private List<BPMLine> BPMLineEntries = new();
[Content] public int BPMFraction = 4;
[Content] public float BPMOffset = 0;
[Content] public float SongOffset = 0;
[Content] public float BPM = 60;
private float onebarDeltaTime;
private void InjectSetSongCurrentTime(float time)
{
// 秒,可见长度,以下相同,注意并非百分比
@@ -170,8 +172,9 @@ namespace Demo.Editor
// BPM
BPM = (float)MainGameController.MainConfig.FindItem(nameof(BPM), BPM);
onebarDeltaTime = 60.0f / (BPM * BPMFraction);
BPMFraction = (int)MainGameController.MainConfig.FindItem(nameof(BPMFraction), BPMFraction);
BPMOffset = (float)MainGameController.MainConfig.FindItem(nameof(BPMOffset), BPMOffset);
SongOffset = (float)MainGameController.MainConfig.FindItem(nameof(SongOffset), SongOffset);
// 绘制时频
var texturePath = (string)MainGameController.MainConfig.FindItem(nameof(SpectrumRenderTexture), null);
@@ -492,7 +495,6 @@ namespace Demo.Editor
var time = MainGameController.CurrentTime;
float onebarDeltaTime = 60.0f / (BPM * BPMFraction);
int BPMLineEntriesIndex = 0;
float farAplha = (1 - SpectrumSeeline.currentPercent) * 0.5f + 0.5f;
float foucs = Mathf.CeilToInt((time + leftClipFrom ) / onebarDeltaTime) * onebarDeltaTime;

View File

@@ -33,12 +33,12 @@ namespace Demo.Editor
{
if (name == nameof(ScriptableObject.LoadSubScript))
{
stream.WriteLine("#define __build_in_pragma #");
stream.WriteLine("#define __build_in_to_text(x) #x");
// stream.WriteLine("#define __build_in_pragma #");
// stream.WriteLine("#define __build_in_to_text(x) #x");
stream.Write("/*\n" + description + "\n*/\n");
stream.Write($"#define {name}({string.Join(',', paramList)}) __build_in_pragma include __build_in_to_text(./##{paramList.First()})\n\n");
//stream.Write($"#define {name}({string.Join(',', paramList)})\n\n");
// stream.Write("/*\n" + description + "\n*/\n");
// stream.Write($"#define {name}({string.Join(',', paramList)}) __build_in_pragma include __build_in_to_text(./##{paramList.First()})\n\n");
stream.Write($"#define {name}({string.Join(',', paramList)})\n\n");
}
else
{

View File

@@ -39,8 +39,8 @@ namespace Demo.Game
public string WhichOpenProject { get; private set; } = null;
public ProjectDefaultFileStyle CurrentProjectDefaultFileStyle = default;
public float SongOffset;
public float CurrentTime => MainAudio.CurrentTime - SongOffset;
public float SongOffset = 0;
public float CurrentTime = 0;
public Transform MainCameraTransform => MainCamera.transform;
@@ -122,10 +122,10 @@ namespace Demo.Game
{
ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen;
ScriptableObject.IsAutoPlay = content.IsAutoPlay;
ScriptableObject.OneBarTime = (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM);
ScriptableObject.OneBarTime = 60.0f / (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM);
SongOffset = (float)MainConfig.FindItem(nameof(SongOffset), SongOffset);
SetupSongDuration = GameContent.instance.SetupSongDuration;
SetSongCurrentTime = GameContent.instance.SetSongCurrentTime;
SongOffset = GameContent.instance.SongOffset;
// Open Project
WhichOpenProject = (string)MainConfig.FindItem(nameof(WhichOpenProject), WhichOpenProject);
if (string.IsNullOrEmpty(WhichOpenProject) == false)
@@ -159,7 +159,7 @@ namespace Demo.Game
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
{
ProjectDefaultFileStyle.PY => ".py",
_ => ".h"
_ => ".cpp"
};
if (content.IsCreateNewProject)
{
@@ -207,7 +207,7 @@ namespace Demo.Game
yield return null;
IsEnableUpdate = true;
yield return new WaitUntil(() => MainObject != null);
MainObject.ScriptUpdate(0, Time.deltaTime, ScriptableObject.TickType.Reset);
MainObject.ScriptUpdate(SongOffset, Time.deltaTime, ScriptableObject.TickType.Reset);
}
@@ -216,9 +216,9 @@ namespace Demo.Game
MainAudio.Stop();
if (IsMain)
{
SetSongCurrentTime(-SongOffset);
SetSongCurrentTime(SongOffset);
}
MainObject.ScriptUpdate(-SongOffset, Time.deltaTime, ScriptableObject.TickType.Reset);
MainObject.ScriptUpdate(SongOffset, Time.deltaTime, ScriptableObject.TickType.Reset);
}
public void Pause()
@@ -255,6 +255,7 @@ namespace Demo.Game
private void Update()
{
CurrentTime = MainAudio.CurrentTime + SongOffset;
float deltaTime = Time.deltaTime;
var currentClip = MainAudio.CurrentClip;

View File

@@ -24,7 +24,7 @@ namespace Demo.Game
}
finally
{
ScriptUpdate(0, 0.01f, TickType.Start);
ScriptUpdate(RootGameController.SongOffset, 0.01f, TickType.Start);
if (RootGameController.IsMain)
{
Keyboard.current.onTextInput += InputCatchChar;

View File

@@ -35,8 +35,7 @@ namespace Demo
public static (string functionName, string[] arguments) ParseFunctionCall(string input)
{
// 匹配函数名和参数部分
string pattern = @"^(\w+)\s*\(\s*(.*?)\s*\)\s*;?$";
Match match = Regex.Match(input, pattern);
Match match = Regex.Match(input, @"^(\w+)\s*\(\s*(.*?)\s*\)\s*;?$");
if (!match.Success)
return (null, new string[0]);
@@ -56,14 +55,84 @@ namespace Demo
if (string.IsNullOrWhiteSpace(argumentsString))
return new string[0];
// 处理字符串字面量和普通参数的正则表达式
string argPattern = @"""(?:[^""\\]|\\.)*""|[^,]+";
var arguments = new List<string>();
int i = 0;
while (i < argumentsString.Length)
{
// 跳过空白字符
while (i < argumentsString.Length && char.IsWhiteSpace(argumentsString[i]))
i++;
// 越界检查
if (i >= argumentsString.Length)
break;
string argument = ExtractArgument(argumentsString, ref i);
if (!string.IsNullOrEmpty(argument))
arguments.Add(argument.Trim());
return Regex.Matches(argumentsString, argPattern)
.Cast<Match>()
.Select(m => m.Value.Trim())
.Where(arg => !string.IsNullOrEmpty(arg))
.ToArray();
// 跳过空白字符
while (i < argumentsString.Length && char.IsWhiteSpace(argumentsString[i]))
i++;
// 越界检查
if (i >= argumentsString.Length)
break;
// 必定是逗号, 否则异常情况
if (argumentsString[i] != ',')
throw new InvalidOperationException("Parser is invalid logic");
i++;
}
return arguments.ToArray();
}
// 提取单个参数的方法,支持花括号和字符串字面量
private static string ExtractArgument(string input, ref int index)
{
int start = index;
if (input[index] == '"')
{
// 处理字符串字面量
index++; // 跳过开始的引号
while (index < input.Length)
{
if (input[index] == '"' && (index == 0 || input[index - 1] != '\\'))
{
index++; // 跳过结束的引号
break;
}
index++;
}
}
else if (input[index] == '{')
{
// 处理花括号内的内容
int braceCount = 0;
while (index < input.Length)
{
if (input[index] == '{')
braceCount++;
else if (input[index] == '}')
braceCount--;
index++;
if (braceCount == 0)
break;
}
}
else
{
// 处理普通参数(直到遇到逗号)
while (index < input.Length && input[index] != ',')
index++;
}
return input[start..index];
}
}
@@ -396,6 +465,28 @@ namespace Demo
}
}
public partial class ScriptableObject
{
[Content] public int UpdatePerFrame = 1;
/// <summary>
/// 指定多少个<see cref="TickType.Update"/>状态的<see cref="UpdateTicks(float, float, TickType)"/>执行一次更新,不会影响到子物体
/// 属于性能优化的高级选项
/// </summary>
/// <param name="frame">间隔帧数, 小于等于1的值代表无论如何都会更新</param>
[ScriptableCall(@"
<summary>
指定多少个Update状态的UpdateTicks执行一次更新,不会影响到子物体
属于性能优化的高级选项
</summary>
<param name=""frame"">间隔帧数, 小于等于1的值代表无论如何都会更新</param>
")]
public void SetUpdatePerFrame(string frame)
{
UpdatePerFrame = Mathf.Max(1, int.Parse(frame));
}
}
/// <summary>
/// <para>使用<see cref="ScriptableCallAttribute"/>标记可编辑脚本所能够调用的函数,并附加注释</para>
/// <para>使用<see cref="DefaultScriptAttribute"/>标记派生类,并附加默认模板</para>
@@ -800,6 +891,7 @@ namespace Demo
//LateUpdate
}
[Content, SerializeField] private int ScriptUpdateCounter = 0;
public void ScriptUpdate(float currentTime, float deltaTime, TickType tickType)
{
if (IsEnableUpdate == false)
@@ -809,7 +901,13 @@ namespace Demo
#if UNITY_EDITOR
s_PreparePerfMarker.Begin(this);
#endif
UpdateTicks(currentTime, deltaTime, tickType);
// UpdateTicks
{
if (ScriptUpdateCounter % UpdatePerFrame == 0)
UpdateTicks(currentTime, deltaTime, tickType);
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
}
// Childs UpdateTicks
foreach (var child in Childs)
{
child.ScriptUpdate(currentTime, deltaTime, tickType);

View File

@@ -224,10 +224,12 @@ namespace Demo.Game
public static Dictionary<string, Func<ScriptableObject>> GetScriptableObjectInstantiate()
{
return new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate.Union(TickUpdatementInstantiate)
.Union(MaterialUpdatementInstantiate)
.Union(SplineInstantiate)
.Union(JudgementInstantiate));
return new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate
.Union(DDTInstantiate)
.Union(TickUpdatementInstantiate)
.Union(MaterialUpdatementInstantiate)
.Union(SplineInstantiate)
.Union(JudgementInstantiate));
}
}
}

View File

@@ -13,9 +13,37 @@ namespace Demo.Game
return new GameObject().AddComponent<SplineTrackRenderer>();
}
public const bool DefaultIsAutoOrient = false;
[Content] public bool IsAutoOrient = DefaultIsAutoOrient;
public override IEnumerator LoadScript(string script)
{
MyLineMaterial = Resources.Load<Material>("Line/Default");
yield return base.LoadScript(script);
}
public override void SetupMeshGenerator(SplineRenderer meshGenerater)
{
base.SetupMeshGenerator(meshGenerater);
meshGenerater.autoUpdate = IsAutoOrient;
}
public override IEnumerator UnloadScript()
{
yield return base.UnloadScript();
// Reset
{
IsAutoOrient = DefaultIsAutoOrient;
}
}
/// <summary>
/// 开启自动面向摄像机的功能
/// </summary>
[ScriptableCall(@"开启自动面向摄像机的功能")]
public void EnableAutoOrient()
{
IsAutoOrient = true;
}
}
}

View File

@@ -13,8 +13,10 @@ namespace Demo.Game
return new GameObject().AddComponent<SplineTubeRenderer>();
}
[Content] public bool IsDoubleSide = true;
[Content] public int SidesCount = 12;
public const bool DefaultIsDoubleSide = true;
public const int DefaultSidesCount = 12;
[Content] public bool IsDoubleSide = DefaultIsDoubleSide;
[Content] public int SidesCount = DefaultSidesCount;
public override IEnumerator LoadScript(string script)
{
@@ -31,10 +33,12 @@ namespace Demo.Game
public override IEnumerator UnloadScript()
{
if (string.IsNullOrEmpty(LinesAssetBundlePath) == false)
yield return this.UnloadAssetBundle(LinesAssetBundlePath);
LinesAssetBundlePath = "";
yield return base.UnloadScript();
// Reset
{
IsDoubleSide = DefaultIsDoubleSide;
SidesCount = DefaultSidesCount;
}
}
/// <summary>

View File

@@ -21,7 +21,7 @@ MonoBehaviour:
m_GetFontFeaturesAtRuntime: 1
m_missingGlyphCharacter: 0
m_warningsDisabled: 0
m_defaultFontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_defaultFontAsset: {fileID: 11400000, guid: 4abb91c83e9e6214992ef15922294c0c, type: 2}
m_defaultFontAssetPath: Fonts & Materials/
m_defaultFontSize: 36
m_defaultAutoSizeMinRatio: 0.5
@@ -29,18 +29,16 @@ MonoBehaviour:
m_defaultTextMeshProTextContainerSize: {x: 20, y: 5}
m_defaultTextMeshProUITextContainerSize: {x: 200, y: 50}
m_autoSizeTextContainer: 0
m_IsTextObjectScaleStatic: 0
m_fallbackFontAssets: []
m_matchMaterialPreset: 1
m_defaultSpriteAsset: {fileID: 11400000, guid: c41005c129ba4d66911b75229fd70b45,
type: 2}
m_defaultSpriteAsset: {fileID: 11400000, guid: c41005c129ba4d66911b75229fd70b45, type: 2}
m_defaultSpriteAssetPath: Sprite Assets/
m_enableEmojiSupport: 1
m_MissingCharacterSpriteUnicode: 0
m_defaultColorGradientPresetsPath: Color Gradient Presets/
m_defaultStyleSheet: {fileID: 11400000, guid: f952c082cb03451daed3ee968ac6c63e,
type: 2}
m_defaultStyleSheet: {fileID: 11400000, guid: f952c082cb03451daed3ee968ac6c63e, type: 2}
m_StyleSheetsResourcePath:
m_leadingCharacters: {fileID: 4900000, guid: d82c1b31c7e74239bff1220585707d2b, type: 3}
m_followingCharacters: {fileID: 4900000, guid: fade42e8bc714b018fac513c043d323b,
type: 3}
m_followingCharacters: {fileID: 4900000, guid: fade42e8bc714b018fac513c043d323b, type: 3}
m_UseModernHangulLineBreakingRules: 0