private bool TryCreateJson() { try { var json = JsonUtility.ToJson(_definitions); if (File.Exists(_filePath)) { File.Delete(_filePath); } File.WriteAllText(_filePath, json); _definitions = JsonUtility.FromJson <ComboDefinitions>(json); ChangeView(); } catch (Exception e) { Debug.LogError(e.Message); return(false); } AssetDatabase.Refresh(); return(true); }
public void ReplaceComboDefinitions(ComboDefinitions newValue) { var index = ConfigComponentsLookup.ComboDefinitions; var component = CreateComponent <ComboDefinitionsComponent>(index); component.value = newValue; ReplaceComponent(index, component); }
public ConfigEntity SetComboDefinitions(ComboDefinitions newValue) { if (hasComboDefinitions) { throw new Entitas.EntitasException("Could not set ComboDefinitions!\n" + this + " already has an entity with ComboDefinitionsComponent!", "You should check if the context already has a comboDefinitionsEntity before setting it or use context.ReplaceComboDefinitions()."); } var entity = CreateEntity(); entity.AddComboDefinitions(newValue); return(entity); }
public void ReplaceComboDefinitions(ComboDefinitions newValue) { var entity = comboDefinitionsEntity; if (entity == null) { entity = SetComboDefinitions(newValue); } else { entity.ReplaceComboDefinitions(newValue); } }
private bool TryReadJson() { try { var json = File.ReadAllText(_filePath); _definitions = JsonUtility.FromJson <ComboDefinitions>(json); ChangeView(); } catch (Exception e) { Debug.LogError(e.Message); return(false); } return(true); }