Ejemplo n.º 1
0
        public void CollectGameObjectMaterial(GameObject go, bool collectChildren = true)
        {
            if (setColorsIDArr == null || setColorsIDArr.Length <= 0)
            {
                return;
            }

            var rendererList = go.GetComponentsInChildren <Renderer>();

            for (int i = 0; i < rendererList.Length; i++)
            {
                var renderer = rendererList[i];
                if (renderer is MeshRenderer || renderer is SkinnedMeshRenderer)
                {
                    if (matDatas.Exists(m => m.Renderer == renderer))
                    {
                        continue;
                    }

                    MaterialData data = new MaterialData(renderer);
                    for (int k = 0; k < setColorsIDArr.Length; k++)
                    {
                        data.AddColorParam(setColorsIDArr[k]);
                    }
                    if (!data.IsEmpty)
                    {
                        matDatas.Add(data);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void CollectGameObjectMaterial(GameObject go, bool collectChildren = true)
        {
            if (setColorsIDArr == null || setColorsIDArr.Length <= 0)
            {
                return;
            }

            var rendererList = go.GetComponentsInChildren <Renderer>();

            for (int i = 0; i < rendererList.Length; i++)
            {
                var mats = rendererList[i].materials;
                for (int j = 0; j < mats.Length; j++)
                {
                    var mat = mats[j];
                    if (matDatas.Exists(m => m.Mat == mat))
                    {
                        continue;
                    }

                    MaterialData data = new MaterialData(mat);
                    for (int k = 0; k < setColorsIDArr.Length; k++)
                    {
                        data.AddColorParam(setColorsIDArr[k]);
                    }
                    if (!data.IsEmpty)
                    {
                        matDatas.Add(data);
                    }
                }
            }
        }