public void RecreateEntityGroupGraph(UTinyEntityGroup.Reference entityGroupRef) { var entityGroup = entityGroupRef.Dereference(Registry); if (null == entityGroup) { return; } m_EntityGroupToGraph[entityGroupRef] = EntityGroupGraph.CreateFromEntityGroup(entityGroup); }
private void UnloadEntityGroup(UTinyEntityGroup.Reference entityGroupRef, bool rebuildWorkspace = true) { if (!m_LoadedEntityGroups.Contains(entityGroupRef)) { Debug.Log($"{UTinyConstants.ApplicationName}: Cannot unload the group named '{entityGroupRef.Name}'. It is not loaded"); return; } if (m_EntityGroupToGraph.ContainsKey(entityGroupRef)) { OnWillUnloadEntityGroup?.Invoke(entityGroupRef); m_EntityGroupToGraph[entityGroupRef].Unlink(); m_EntityGroupToGraph.Remove(entityGroupRef); } m_LoadedEntityGroups.Remove(entityGroupRef); var entityGroup = entityGroupRef.Dereference(Registry); if (null != entityGroup) { Undo.FlushChanges(entityGroup); Undo.FlushChanges(entityGroup.Entities.Deref(entityGroup.Registry)); } if (m_LoadedEntityGroups.Count == 0) { SetActiveEntityGroup(UTinyEntityGroup.Reference.None, rebuildWorkspace); } else { if (entityGroupRef.Id == ActiveEntityGroup.Id) { SetActiveEntityGroup(m_LoadedEntityGroups[0]); } } if (rebuildWorkspace) { RebuildWorkspace(); } OnEntityGroupUnloaded?.Invoke(entityGroupRef); }
private void LoadEntityGroup(UTinyEntityGroup.Reference entityGroupRef, int index, bool rebuildWorkspace) { var entityGroup = entityGroupRef.Dereference(Registry); if (null == entityGroup) { Debug.Log($"{UTinyConstants.ApplicationName}: Could not load group named '{entityGroupRef.Name}' as the reference could not be resolved."); return; } if (m_LoadedEntityGroups.Contains(entityGroupRef)) { Debug.Log($"{UTinyConstants.ApplicationName}: Cannot load the group named '{entityGroupRef.Name}'. It is already loaded"); return; } if (HierarchyHelper.GetOrGenerateScratchPad(m_Context)) { OnWillLoadEntityGroup?.Invoke(entityGroupRef); if (index >= 0 && index < m_LoadedEntityGroups.Count) { m_LoadedEntityGroups.Insert(index, entityGroupRef); } else { m_LoadedEntityGroups.Add(entityGroupRef); } m_EntityGroupToGraph[entityGroupRef] = EntityGroupGraph.CreateFromEntityGroup(entityGroup); } if (rebuildWorkspace) { RebuildWorkspace(); } SetActiveEntityGroup(entityGroupRef, rebuildWorkspace); OnEntityGroupLoaded?.Invoke(entityGroupRef); }