public void RecreateGroups(Dictionary <CacheProceduralObject, ProceduralObject> createdObjects)
        {
            if (groupInformation == null)
            {
                return;
            }
            if (groupInformation.Count == 0)
            {
                return;
            }

            foreach (var kvp in createdObjects)
            {
                if (!groupInformation.ContainsKey(kvp.Key))
                {
                    continue;
                }

                if (createdObjects[groupInformation[kvp.Key]].group == null)
                {
                    var group = POGroup.CreateGroupWithRoot(createdObjects[groupInformation[kvp.Key]]);
                    ProceduralObjectsLogic.instance.groups.Add(group);
                }
                createdObjects[groupInformation[kvp.Key]].group.AddToGroup(kvp.Value);
            }
        }
        public static List <POGroup> BuildGroupsFromData(this ProceduralObjectsLogic logic)
        {
            var poGroups = new List <POGroup>();

            try
            {
                foreach (var po in logic.proceduralObjects)
                {
                    if (po._groupRootIdData == -2)
                    {
                        continue;
                    }
                    if (po._groupRootIdData == -1)
                    {
                        if (po.group == null)
                        {
                            poGroups.Add(POGroup.CreateGroupWithRoot(po));
                        }
                    }
                    else
                    {
                        var root = logic.proceduralObjects.GetObjectWithId(po._groupRootIdData);
                        if (root == null)
                        {
                            Debug.LogWarning("[ProceduralObjects] Object #" + po.id + " was supposed to be part of a group but the root could not be found ! Assigning no group.");
                            continue;
                        }
                        if (root.group == null)
                        {
                            poGroups.Add(POGroup.CreateGroupWithRoot(root));
                        }

                        root.group.AddToGroup(po);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError("[ProceduralObjects] Error while loading the groups. Skipping all together. " + e);
            }
            return(poGroups);
        }