public void Reset() { ComponentPools.Clear(); #if UNITY_EDITOR GroupedComponents.Clear(); #endif _newEnt = new Entity(); EntityName = ""; UnityDrawerStatics.RefreshPrefabList(); UnityDrawerStatics.RefreshEntityList(); UnityDrawerStatics.RefreshComponentList(); //FindAllComponents(); //OnDataChanged?.Invoke(); IsDirty = false; AvoidDirtyFlag = true; }
public void SaveEntityToJson() { _newEnt = new Entity(FileOps.GetEntityNameFromFullName(EntityName)); //_newEnt = new Entity(EntityName); Debug.Log($"Saving entity: {EntityName}"); foreach (var typ in ComponentPools) { foreach (var cmp in typ.Value) { //Debug.Log($"Adding comp from gui: {cmp.ObjectType.Name}"); _newEnt.AddComponentFromGUI(cmp); cmp.SetId(Guid.Empty); //Keep this out of prod code } } _newEnt.IsPooled = ShouldPoolEntity; Serializer.TrySerialize(typeof(Entity), _newEnt, out _data).AssertSuccess(); var filePath = Application.dataPath + "/Resources/Entities/" + EntityName + ".json"; Directory.CreateDirectory(Application.dataPath + "/Resources/Entities/" + FileOps.GetTypeFromFullName(EntityName) + "/"); using (var file = File.Open(filePath, FileMode.Create)) { using (var writer = new StreamWriter(file)) { fsJsonPrinter.PrettyJson(_data, writer); } } IsDirty = false; AssetDatabase.Refresh(); UnityDrawerStatics.RefreshEntityList(); AvoidDirtyFlag = true; }