Пример #1
0
    private static void CreateNewGroupFor(MegaMeshComponent component, bool AddImmediate = false)
    {
        MegaMeshGroup newgroup = Object.Instantiate(Prefabs.CombinedMeshGroup, Transforms.MegaMeshParent).AddComponent <MegaMeshGroup>();

        newgroup.MaterialType = component.MaterialType;

        // add newgroup to the appropriate list inside the appropriate dictionary. If the appropriate list doesn't exist, create it
        if (component.MaterialType == MaterialType.CircuitBoard)
        {
            if (!BoardMegaMeshGroups.ContainsKey(component.Color))
            {
                BoardMegaMeshGroups.Add(component.Color, new HashSet <MegaMeshGroup>());
            }
            BoardMegaMeshGroups[component.Color].Add(newgroup);

            newgroup.Renderer.material = Materials.BoardOfColor(component.Color);
        }
        else if (component.MaterialType == MaterialType.SolidColor)
        {
            if (!SolidColorMegaMeshGroups.ContainsKey(component.Color))
            {
                SolidColorMegaMeshGroups.Add(component.Color, new HashSet <MegaMeshGroup>());
            }
            SolidColorMegaMeshGroups[component.Color].Add(newgroup);

            newgroup.Renderer.material = Materials.SolidColor(component.Color);
        }
        else
        {
            SetNonColorableGroupMaterial(newgroup);
            if (!StandardizedMegaMeshGroups.ContainsKey(component.MaterialType))
            {
                StandardizedMegaMeshGroups.Add(component.MaterialType, new HashSet <MegaMeshGroup>());
            }
            StandardizedMegaMeshGroups[component.MaterialType].Add(newgroup);
        }

        newgroup.AddComponent(component, AddImmediate); // add the component to the new group
    }