继续推动Config更新(本机测试发生错误)
This commit is contained in:
@@ -42,10 +42,11 @@ namespace Demo.Game
|
||||
[Content] public bool IsSetObjectDisable = false;
|
||||
[Content] public int UpdatePerFrame = 1;
|
||||
|
||||
[Setting] public string ScriptName = "";
|
||||
private int[] ChildTypes = null;
|
||||
private string[] ChildNames = null;
|
||||
private ScriptLoadableConfig[] childs = null;
|
||||
|
||||
|
||||
[Setting] public ScriptableObject target;
|
||||
|
||||
public virtual void Deserialize(BinaryReader reader)
|
||||
@@ -56,14 +57,13 @@ namespace Demo.Game
|
||||
EnterGameLocalScaling = BinarySerializeUtility.ReadVec3(reader);
|
||||
IsSetObjectDisable = BinarySerializeUtility.ReadBool(reader);
|
||||
UpdatePerFrame = BinarySerializeUtility.ReadInt(reader);
|
||||
ScriptName = BinarySerializeUtility.ReadString(reader);
|
||||
ChildTypes = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
ChildNames = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
int childCount = ChildTypes.Length;
|
||||
childs = new ScriptLoadableConfig[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
var scriptObject = DefaultInstantiate.GetScriptableObjectInstantiate()[DefaultInstantiate.ScriptableObjectID2Typename[ChildTypes[i]]].Invoke();
|
||||
scriptObject.EnableScript(target);
|
||||
var scriptObject = target.NewSubScript(DefaultInstantiate.ScriptableObjectID2Typename[ChildTypes[i]], ChildNames[i]);
|
||||
childs[i] = scriptObject.Config;
|
||||
childs[i].Deserialize(reader);
|
||||
}
|
||||
@@ -76,10 +76,11 @@ namespace Demo.Game
|
||||
BinarySerializeUtility.WriteVec3(writer, EnterGameLocalScaling);
|
||||
BinarySerializeUtility.WriteBool(writer, IsSetObjectDisable);
|
||||
BinarySerializeUtility.WriteInt(writer, UpdatePerFrame);
|
||||
BinarySerializeUtility.WriteString(writer, ScriptName);
|
||||
childs = (from child in target.Childs select child.Config).ToArray();
|
||||
ChildTypes = (from child in childs select DefaultInstantiate.ScriptableObjectTypename2ID[child.target.GetType().Name]).ToArray();
|
||||
ChildNames = (from child in childs select child.target.ScriptName).ToArray();
|
||||
BinarySerializeUtility.SerializeArray(writer, ChildTypes);
|
||||
BinarySerializeUtility.SerializeArray(writer, ChildNames);
|
||||
foreach (var child in childs)
|
||||
{
|
||||
child.Serialize(writer);
|
||||
@@ -227,11 +228,7 @@ namespace Demo.Game
|
||||
public static float OneBarTime = 60;
|
||||
|
||||
private bool isEnableScript = false;
|
||||
public string ScriptName
|
||||
{
|
||||
get => Config.ScriptName;
|
||||
set => Config.ScriptName = value;
|
||||
}
|
||||
[Setting] public string ScriptName;
|
||||
private string s_ScriptType = null;
|
||||
public string m_ScriptType
|
||||
{
|
||||
@@ -338,7 +335,7 @@ namespace Demo.Game
|
||||
return result;
|
||||
}
|
||||
|
||||
public void EnableScript(ScriptableObject parent,int uid = -1)
|
||||
public void EnableScript(ScriptableObject parent)
|
||||
{
|
||||
if (isEnableScript)
|
||||
{
|
||||
@@ -360,12 +357,13 @@ namespace Demo.Game
|
||||
|
||||
this.name = ScriptName;
|
||||
|
||||
isEnableScript = true;
|
||||
// 只有RootObject的parent会是空的
|
||||
if (uid < 0)
|
||||
if (Config.UID < 0)
|
||||
Config.UID = GetRoot().PushLoadedScriptObject(this);
|
||||
else
|
||||
GetRoot().PushLoadedScriptObject(this, uid);
|
||||
GetRoot().PushLoadedScriptObject(this, Config.UID);
|
||||
|
||||
isEnableScript = true;
|
||||
// 只有RootObject的parent会是空的
|
||||
if (parent != null)
|
||||
{
|
||||
MyHierarchyItem = parent.MyHierarchyItem.GetHierarchyItem().CreateSubPropertyItem(1)[0];
|
||||
|
||||
Reference in New Issue
Block a user