public static List <SceneCellItemCombineGroup> Grouping(CombineGroupType groupBy, List <GameObject> gameObjects) { Dictionary <UnityEngine.Object, SceneCellItemCombineGroup> groupDic = new Dictionary <UnityEngine.Object, SceneCellItemCombineGroup>(); foreach (var gameObject in gameObjects) { var renderer = gameObject.GetComponent <Renderer>(); if (renderer == null) { continue; } var shader = renderer.sharedMaterial.shader; if (!groupDic.ContainsKey(shader)) { var newGroup = new SceneCellItemCombineGroup(); groupDic.Add(shader, newGroup); newGroup.groupByObj = shader; newGroup.groupInfo = shader.ToString(); } groupDic[shader].groupGameObjects.Add(gameObject); } var groups = groupDic.ToValuesList(); return(groups); }
private void GroupingGameObjects() { cellItemGroups = SceneCellItemCombineGroup.Grouping(CombineInGroupBy, CurrentCellItems); }