コード例 #1
0
        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);
        }
コード例 #2
0
 private void GroupingGameObjects()
 {
     cellItemGroups = SceneCellItemCombineGroup.Grouping(CombineInGroupBy, CurrentCellItems);
 }