推进中, 解析存在错误
This commit is contained in:
Submodule Assets/Convention updated: fced17765c...0b563f393b
@@ -1,10 +1,11 @@
|
|||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Convention;
|
using Convention;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Demo.Game
|
namespace Demo.Game
|
||||||
{
|
{
|
||||||
public class DDT : ScriptableObject
|
public class DDT : ScriptableObject, IEnumerable<float>
|
||||||
{
|
{
|
||||||
public static DDT Make()
|
public static DDT Make()
|
||||||
{
|
{
|
||||||
@@ -24,5 +25,23 @@ namespace Demo.Game
|
|||||||
{
|
{
|
||||||
Datas.Add((barCount + tickCount / (float)barSplitTimes) * OneBarTime);
|
Datas.Add((barCount + tickCount / (float)barSplitTimes) * OneBarTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Convention.RScript.Variable.Attr.Method]
|
||||||
|
public float At(int index)
|
||||||
|
{
|
||||||
|
return Datas[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<float> GetEnumerator()
|
||||||
|
{
|
||||||
|
return ((IEnumerable<float>)Datas).GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return ((IEnumerable)Datas).GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count => Datas.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ namespace Demo.Editor
|
|||||||
{
|
{
|
||||||
LastLoadProjectName = ProjectName;
|
LastLoadProjectName = ProjectName;
|
||||||
StopRefreshFlag = false;
|
StopRefreshFlag = false;
|
||||||
MainGameController = FindObjectOfType<GameController>();
|
MainGameController = FindFirstObjectByType<GameController>();
|
||||||
MainGameController.IsMain = true;
|
MainGameController.IsMain = true;
|
||||||
StartCoroutine(MainGameController.GameInit());
|
StartCoroutine(MainGameController.GameInit());
|
||||||
};
|
};
|
||||||
@@ -378,25 +378,30 @@ namespace Demo.Editor
|
|||||||
{
|
{
|
||||||
GlobalConfig.ConstConfigFile = "config.easysave";
|
GlobalConfig.ConstConfigFile = "config.easysave";
|
||||||
// Generate Framework
|
// Generate Framework
|
||||||
var generaters = DefaultInstantiate.GetScriptableObjectInstantiate();
|
|
||||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
|
||||||
{
|
{
|
||||||
foreach (var type in asm.GetTypes())
|
var generaters = DefaultInstantiate.GetScriptableObjectInstantiate();
|
||||||
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
string filename = Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater.GetTypename(type);
|
foreach (var type in asm.GetTypes())
|
||||||
if (Convention.RScript.Variable.RScriptInjectVariableGenerater.AllRScriptInjectVariables.ContainsKey(filename))
|
|
||||||
continue;
|
|
||||||
if (generaters.TryGetValue(filename, out var generater))
|
|
||||||
{
|
{
|
||||||
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, () => generater(), null, filename).Register();
|
string filename = Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater.GetTypename(type);
|
||||||
Debug.Log($"{filename} register");
|
if (Convention.RScript.Variable.RScriptInjectVariableGenerater.AllRScriptInjectVariables.ContainsKey(filename))
|
||||||
}
|
continue;
|
||||||
else if (typeof(ScriptableObject).IsAssignableFrom(type))
|
if (generaters.TryGetValue(filename, out var generater))
|
||||||
{
|
{
|
||||||
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, null, null, filename).Register();
|
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, () => generater(), null, filename).Register();
|
||||||
Debug.Log($"{filename} register");
|
Debug.Log($"{filename} register");
|
||||||
|
}
|
||||||
|
else if (typeof(ScriptableObject).IsAssignableFrom(type))
|
||||||
|
{
|
||||||
|
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, null, null, filename).Register();
|
||||||
|
Debug.Log($"{filename} register");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(
|
||||||
|
typeof(MathExtension.EaseCurveType), null, null, nameof(MathExtension.EaseCurveType) + "Getter").Register();
|
||||||
|
Debug.Log($"{typeof(MathExtension.EaseCurveType)} register");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper Files
|
// Helper Files
|
||||||
|
|||||||
@@ -194,19 +194,26 @@ namespace Demo.Game
|
|||||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||||
rootObject.MustExistsPath();
|
rootObject.MustExistsPath();
|
||||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||||
|
MainObject = rootGameObject;
|
||||||
rootGameObject.transform.SetParent(transform);
|
rootGameObject.transform.SetParent(transform);
|
||||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||||
rootGameObject.audioSystem = MainAudio;
|
rootGameObject.audioSystem = MainAudio;
|
||||||
rootGameObject.EnableScript(content.RootSourceDir, this);
|
rootGameObject.EnableScript(content.RootSourceDir, this);
|
||||||
try
|
rootGameObject.SetContent(nameof(SongOffset), SongOffset);
|
||||||
|
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
||||||
|
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
||||||
|
yield return rootGameObject.ParseScript2Expr(rootObject.LoadAsText());
|
||||||
|
yield return rootGameObject.ApplyScript();
|
||||||
|
IEnumerator DFS(ScriptableObject parent)
|
||||||
{
|
{
|
||||||
yield return rootGameObject.ParseScript2Expr(rootObject.LoadAsText());
|
foreach (var child in parent.Childs)
|
||||||
yield return rootGameObject.ApplyScript();
|
{
|
||||||
}
|
if (child.IsScriptApply == false)
|
||||||
finally
|
yield return child.ApplyScript();
|
||||||
{
|
yield return DFS(child);
|
||||||
MainObject = rootGameObject;
|
}
|
||||||
}
|
}
|
||||||
|
yield return DFS(rootGameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -109,9 +109,10 @@ namespace Demo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ScriptableObject
|
public partial class ScriptableObject
|
||||||
{
|
{
|
||||||
public Dictionary<string, object> ScriptableObjectContents = new();
|
public Dictionary<string, float> ScriptableObjectContents = new();
|
||||||
|
|
||||||
public object GetContent(string key)
|
[Convention.RScript.Variable.Attr.Method]
|
||||||
|
public float GetContent(string key)
|
||||||
{
|
{
|
||||||
if (ScriptableObjectContents.TryGetValue(key, out var result))
|
if (ScriptableObjectContents.TryGetValue(key, out var result))
|
||||||
{
|
{
|
||||||
@@ -121,12 +122,14 @@ namespace Demo
|
|||||||
{
|
{
|
||||||
return Parent.GetContent(key);
|
return Parent.GetContent(key);
|
||||||
}
|
}
|
||||||
return null;
|
throw new InvalidOperationException($"Key {key} is not find in contnet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetContent(string key, object value)
|
[Convention.RScript.Variable.Attr.Method]
|
||||||
|
public float SetContent(string key, float value)
|
||||||
{
|
{
|
||||||
ScriptableObjectContents[key] = value;
|
ScriptableObjectContents[key] = value;
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +302,7 @@ namespace Demo
|
|||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Convention.RScript.Variable.Attr.Method]
|
[Convention.RScript.Variable.Attr.Method]
|
||||||
public ScriptableObject NewSubScript([In] string type, [In] string name, [In] string path)
|
public ScriptableObject LoadSubScript([In] string type, [In] string name, [In] string path)
|
||||||
{
|
{
|
||||||
// 判断类型是否合法
|
// 判断类型是否合法
|
||||||
if (DefaultInstantiate.GetScriptableObjectInstantiate().TryGetValue(type, out var creater) == false)
|
if (DefaultInstantiate.GetScriptableObjectInstantiate().TryGetValue(type, out var creater) == false)
|
||||||
@@ -390,6 +393,8 @@ namespace Demo
|
|||||||
RScriptImportClass importClass = new()
|
RScriptImportClass importClass = new()
|
||||||
{
|
{
|
||||||
typeof(Mathf),
|
typeof(Mathf),
|
||||||
|
typeof(UnityEngine.Random),
|
||||||
|
typeof(MathExtension.EaseCurveType)
|
||||||
};
|
};
|
||||||
RScriptVariables variables = new()
|
RScriptVariables variables = new()
|
||||||
{
|
{
|
||||||
@@ -403,7 +408,11 @@ namespace Demo
|
|||||||
return engine.RunAsync(script, importClass, variables);
|
return engine.RunAsync(script, importClass, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Content] private bool IsEnableUpdate = false;
|
[Content]
|
||||||
|
public bool IsScriptApply
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
} = false;
|
||||||
|
|
||||||
public enum TickType
|
public enum TickType
|
||||||
{
|
{
|
||||||
@@ -416,7 +425,7 @@ namespace Demo
|
|||||||
[Content, SerializeField] private int ScriptUpdateCounter = 0;
|
[Content, SerializeField] private int ScriptUpdateCounter = 0;
|
||||||
public void ScriptUpdate(float currentTime, float deltaTime, TickType tickType)
|
public void ScriptUpdate(float currentTime, float deltaTime, TickType tickType)
|
||||||
{
|
{
|
||||||
if (IsEnableUpdate == false)
|
if (IsScriptApply == false)
|
||||||
return;
|
return;
|
||||||
if (gameObject.activeInHierarchy == false)
|
if (gameObject.activeInHierarchy == false)
|
||||||
return;
|
return;
|
||||||
@@ -480,7 +489,7 @@ namespace Demo
|
|||||||
AllScriptableObjectCounter++;
|
AllScriptableObjectCounter++;
|
||||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||||
}
|
}
|
||||||
IsEnableUpdate = true;
|
IsScriptApply = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IEnumerator UnloadScript()
|
public virtual IEnumerator UnloadScript()
|
||||||
@@ -497,22 +506,25 @@ namespace Demo
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// 清理各种状态
|
this.isEnableScript = false;
|
||||||
IsEnableUpdate = false;
|
this.Parent = null;
|
||||||
|
this.name = "<Unload>";
|
||||||
|
if (IsScriptApply)
|
||||||
|
{
|
||||||
|
// 清理各种状态
|
||||||
|
IsScriptApply = false;
|
||||||
|
// 清理Cache
|
||||||
|
//
|
||||||
|
// 减数
|
||||||
|
AllScriptableObjectCounter--;
|
||||||
|
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||||
|
}
|
||||||
if (MyHierarchyItem != null)
|
if (MyHierarchyItem != null)
|
||||||
{
|
{
|
||||||
// 卸载UI
|
// 卸载UI
|
||||||
MyHierarchyItem.Release();
|
MyHierarchyItem.Release();
|
||||||
MyHierarchyItem = null;
|
MyHierarchyItem = null;
|
||||||
}
|
}
|
||||||
this.isEnableScript = false;
|
|
||||||
this.Parent = null;
|
|
||||||
this.name = "<Unload>";
|
|
||||||
// 清理Cache
|
|
||||||
//
|
|
||||||
// 减数
|
|
||||||
AllScriptableObjectCounter--;
|
|
||||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule Assets/Scripts/Framework/[RScript] updated: 5b235a7f26...2f24d94db2
@@ -42,7 +42,7 @@ namespace Demo.Game
|
|||||||
{
|
{
|
||||||
var spline = self.SharedInterfaceScriptObject.FindWithPath(path, false);
|
var spline = self.SharedInterfaceScriptObject.FindWithPath(path, false);
|
||||||
if (spline == null)
|
if (spline == null)
|
||||||
spline = self.SharedInterfaceScriptObject.NewSubScript(nameof(SplineCore), new ToolFile(path).GetFilename(true), path);
|
spline = self.SharedInterfaceScriptObject.LoadSubScript(nameof(SplineCore), new ToolFile(path).GetFilename(true), path);
|
||||||
self.MySplineCore = (SplineCore)spline;
|
self.MySplineCore = (SplineCore)spline;
|
||||||
return self.MySplineCore;
|
return self.MySplineCore;
|
||||||
}
|
}
|
||||||
@@ -145,9 +145,9 @@ namespace Demo.Game
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">脚本位置</param>
|
/// <param name="path">脚本位置</param>
|
||||||
[Convention.RScript.Variable.Attr.Method]
|
[Convention.RScript.Variable.Attr.Method]
|
||||||
public void LoadNode(ScriptableObject node)
|
public void LoadNode(SplineNode node)
|
||||||
{
|
{
|
||||||
MySplineNodes.Add(node.GetOrAddComponent<SplineNode>());
|
MySplineNodes.Add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user