推进中, 解析存在错误
This commit is contained in:
Submodule Assets/Convention updated: fced17765c...0b563f393b
@@ -1,10 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public class DDT : ScriptableObject
|
||||
public class DDT : ScriptableObject, IEnumerable<float>
|
||||
{
|
||||
public static DDT Make()
|
||||
{
|
||||
@@ -24,5 +25,23 @@ namespace Demo.Game
|
||||
{
|
||||
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;
|
||||
StopRefreshFlag = false;
|
||||
MainGameController = FindObjectOfType<GameController>();
|
||||
MainGameController = FindFirstObjectByType<GameController>();
|
||||
MainGameController.IsMain = true;
|
||||
StartCoroutine(MainGameController.GameInit());
|
||||
};
|
||||
@@ -378,25 +378,30 @@ namespace Demo.Editor
|
||||
{
|
||||
GlobalConfig.ConstConfigFile = "config.easysave";
|
||||
// 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);
|
||||
if (Convention.RScript.Variable.RScriptInjectVariableGenerater.AllRScriptInjectVariables.ContainsKey(filename))
|
||||
continue;
|
||||
if (generaters.TryGetValue(filename, out var generater))
|
||||
foreach (var type in asm.GetTypes())
|
||||
{
|
||||
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, () => generater(), null, 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");
|
||||
string filename = Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater.GetTypename(type);
|
||||
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();
|
||||
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
|
||||
|
||||
@@ -194,19 +194,26 @@ namespace Demo.Game
|
||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||
rootObject.MustExistsPath();
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
MainObject = rootGameObject;
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
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());
|
||||
yield return rootGameObject.ApplyScript();
|
||||
}
|
||||
finally
|
||||
{
|
||||
MainObject = rootGameObject;
|
||||
foreach (var child in parent.Childs)
|
||||
{
|
||||
if (child.IsScriptApply == false)
|
||||
yield return child.ApplyScript();
|
||||
yield return DFS(child);
|
||||
}
|
||||
}
|
||||
yield return DFS(rootGameObject);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -109,9 +109,10 @@ namespace Demo
|
||||
/// </summary>
|
||||
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))
|
||||
{
|
||||
@@ -121,12 +122,14 @@ namespace Demo
|
||||
{
|
||||
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;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +302,7 @@ namespace Demo
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[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)
|
||||
@@ -390,6 +393,8 @@ namespace Demo
|
||||
RScriptImportClass importClass = new()
|
||||
{
|
||||
typeof(Mathf),
|
||||
typeof(UnityEngine.Random),
|
||||
typeof(MathExtension.EaseCurveType)
|
||||
};
|
||||
RScriptVariables variables = new()
|
||||
{
|
||||
@@ -403,7 +408,11 @@ namespace Demo
|
||||
return engine.RunAsync(script, importClass, variables);
|
||||
}
|
||||
|
||||
[Content] private bool IsEnableUpdate = false;
|
||||
[Content]
|
||||
public bool IsScriptApply
|
||||
{
|
||||
get; private set;
|
||||
} = false;
|
||||
|
||||
public enum TickType
|
||||
{
|
||||
@@ -416,7 +425,7 @@ namespace Demo
|
||||
[Content, SerializeField] private int ScriptUpdateCounter = 0;
|
||||
public void ScriptUpdate(float currentTime, float deltaTime, TickType tickType)
|
||||
{
|
||||
if (IsEnableUpdate == false)
|
||||
if (IsScriptApply == false)
|
||||
return;
|
||||
if (gameObject.activeInHierarchy == false)
|
||||
return;
|
||||
@@ -480,7 +489,7 @@ namespace Demo
|
||||
AllScriptableObjectCounter++;
|
||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||
}
|
||||
IsEnableUpdate = true;
|
||||
IsScriptApply = true;
|
||||
}
|
||||
|
||||
public virtual IEnumerator UnloadScript()
|
||||
@@ -497,22 +506,25 @@ namespace Demo
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 清理各种状态
|
||||
IsEnableUpdate = false;
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
if (IsScriptApply)
|
||||
{
|
||||
// 清理各种状态
|
||||
IsScriptApply = false;
|
||||
// 清理Cache
|
||||
//
|
||||
// 减数
|
||||
AllScriptableObjectCounter--;
|
||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||
}
|
||||
if (MyHierarchyItem != null)
|
||||
{
|
||||
// 卸载UI
|
||||
MyHierarchyItem.Release();
|
||||
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);
|
||||
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;
|
||||
return self.MySplineCore;
|
||||
}
|
||||
@@ -145,9 +145,9 @@ namespace Demo.Game
|
||||
/// </summary>
|
||||
/// <param name="path">脚本位置</param>
|
||||
[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