public static EntityGroupGraph CreateFromEntityGroup(UTinyEntityGroup entityGroup) { var graph = new EntityGroupGraph(entityGroup); graph.SyncFromUTiny(); foreach (var entity in entityGroup.Entities.Select(entityRef => entityRef.Dereference(entityGroup.Registry))) { if (null == entity) { continue; } entity.EntityGroup = entityGroup; graph.CreateLink(entity); } graph.CommitToUnity(); foreach (var entity in entityGroup.Entities.Select(entityRef => entityRef.Dereference(entityGroup.Registry))) { if (null == entity) { continue; } BindingsHelper.RunAllBindings(entity); } return(graph); }
public void RecreateEntityGroupGraph(UTinyEntityGroup.Reference entityGroupRef) { var entityGroup = entityGroupRef.Dereference(Registry); if (null == entityGroup) { return; } m_EntityGroupToGraph[entityGroupRef] = EntityGroupGraph.CreateFromEntityGroup(entityGroup); }
public void RecreateEntityGroupGraphs() { foreach (var entityGroupRef in LoadedEntityGroups) { var entityGroup = entityGroupRef.Dereference(Registry); if (null == entityGroup) { continue; } m_EntityGroupToGraph[entityGroupRef] = EntityGroupGraph.CreateFromEntityGroup(entityGroup); } }
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); }
public EntityGroupGraph GetSceneGraph(UTinyEntityGroup.Reference entityGroupRef) { EntityGroupGraph graph = null; return(m_EntityGroupToGraph.TryGetValue(entityGroupRef, out graph) ? graph : null); }