异步加载已修复, Config更新正推动
This commit is contained in:
@@ -38,12 +38,12 @@ namespace Demo.Game
|
||||
public class ScriptLoadableConfig
|
||||
{
|
||||
[Content] public int UID = -1;
|
||||
[Content] public Vector3 EnterGameLocalPosition = Vector3.zero, EnterGameEulerAngles = Vector3.zero, EnterGameLocalScaling = Vector3.zero;
|
||||
[Content] public Vector3 EnterGameLocalPosition = Vector3.zero, EnterGameEulerAngles = Vector3.zero, EnterGameLocalScaling = Vector3.one;
|
||||
[Content] public bool IsSetObjectDisable = false;
|
||||
[Content] public int UpdatePerFrame = 1;
|
||||
|
||||
[Setting] public string ScriptName = "";
|
||||
private string[] ChildTypes = null;
|
||||
private int[] ChildTypes = null;
|
||||
private ScriptLoadableConfig[] childs = null;
|
||||
|
||||
[Setting] public ScriptableObject target;
|
||||
@@ -57,12 +57,12 @@ namespace Demo.Game
|
||||
IsSetObjectDisable = BinarySerializeUtility.ReadBool(reader);
|
||||
UpdatePerFrame = BinarySerializeUtility.ReadInt(reader);
|
||||
ScriptName = BinarySerializeUtility.ReadString(reader);
|
||||
ChildTypes = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
ChildTypes = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
int childCount = ChildTypes.Length;
|
||||
childs = new ScriptLoadableConfig[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
var scriptObject = DefaultInstantiate.GetScriptableObjectInstantiate()[ChildTypes[i]].Invoke();
|
||||
var scriptObject = DefaultInstantiate.GetScriptableObjectInstantiate()[DefaultInstantiate.ScriptableObjectID2Typename[ChildTypes[i]]].Invoke();
|
||||
scriptObject.EnableScript(target);
|
||||
childs[i] = scriptObject.Config;
|
||||
childs[i].Deserialize(reader);
|
||||
@@ -78,7 +78,7 @@ namespace Demo.Game
|
||||
BinarySerializeUtility.WriteInt(writer, UpdatePerFrame);
|
||||
BinarySerializeUtility.WriteString(writer, ScriptName);
|
||||
childs = (from child in target.Childs select child.Config).ToArray();
|
||||
ChildTypes = (from child in childs select child.GetType().Name).ToArray();
|
||||
ChildTypes = (from child in childs select DefaultInstantiate.ScriptableObjectTypename2ID[child.target.GetType().Name]).ToArray();
|
||||
BinarySerializeUtility.SerializeArray(writer, ChildTypes);
|
||||
foreach (var child in childs)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLocalPosition(float x, float y, float z)
|
||||
{
|
||||
Config.EnterGameLocalPosition = new(x, y, z);
|
||||
Config.EnterGameLocalPosition = transform.localPosition = new(x, y, z);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置欧拉角
|
||||
@@ -144,7 +144,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLocalEulerAngles(float x, float y, float z)
|
||||
{
|
||||
Config.EnterGameEulerAngles = new(x, y, z);
|
||||
Config.EnterGameEulerAngles = transform.localEulerAngles = new(x, y, z);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置缩放
|
||||
@@ -155,7 +155,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLocalScaling(float x, float y, float z)
|
||||
{
|
||||
Config.EnterGameLocalScaling = new(x, y, z);
|
||||
Config.EnterGameLocalScaling = transform.localScale= new(x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,6 +166,7 @@ namespace Demo.Game
|
||||
public void SetObjectDisable()
|
||||
{
|
||||
Config.IsSetObjectDisable = true;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -678,9 +679,12 @@ namespace Demo.Game
|
||||
MyHierarchyItem.Release();
|
||||
MyHierarchyItem = null;
|
||||
}
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
if (this /*防假空*/)
|
||||
{
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user