private void SerlalizeBT(Type type) { if (typeof(BehaviorManager.BehaviorTree) == type.BaseType) { BehaviorManager.BehaviorTree instance = Activator.CreateInstance(type) as BehaviorManager.BehaviorTree; // the type is invalide if (null == instance) { #if UNITY_EDITOR Debug.Log("instance is null"); #endif BehaviorManager.BehaviorTree instanceWithAQN = Activator.CreateInstance(BehaviorTreeUtility.GetAssemblyQualifiedType(type.FullName)) as BehaviorManager.BehaviorTree; if (null != instanceWithAQN) { #if UNITY_EDITOR Debug.Log("Serilize the BehaviorTree : " + type.FullName); BehaviorTreeSerialize.Save(instanceWithAQN); #endif } } else { #if UNITY_EDITOR Debug.Log("Serilize the BehaviorTree : " + type.FullName); BehaviorTreeSerialize.Save(instance); #endif } } }
public void OnSerializeButtonClick() { // 服务器调用序列化 string serializationFilePath = BehaviorTreeSerialize.Save(m_BTServerCreated); // 客户端调用反序列化 if ("" == serializationFilePath) { #if UNITY_EDITOR Debug.LogWarning("Serialize ERRROR... CAN'T Deserialize"); #endif } else { m_deserializeBT.OnDeserializeAssetToBehavior(serializationFilePath); } }