示例#1
0
        /// <summary>
        /// 收集依赖
        /// </summary>
        public static ResDepLightMap CollectDependencies(GameObject go, bool bCollectChildren)
        {
            if (LightmapSettings.lightmaps.Length < 1)
            {
                return(null);
            }

            // 收集LightMap索引
            var renderers = new List <Renderer>();

            EditorUtil.VisitComponents <Renderer>(go, bCollectChildren, renderer =>
            {
                var index = renderer.lightmapIndex;
                if (index < 0 || index >= LightmapSettings.lightmaps.Length)
                {
                    return;
                }
                renderers.Add(renderer);
            });


            if (renderers.Count < 1)
            {
                return(null);
            }

            ResDepLightMap dep = null;

            for (int i = 0, ci = renderers.Count; i < ci; ++i)
            {
                var renderer = renderers[i];
                var data     = LightmapSettings.lightmaps[renderer.lightmapIndex];
                if (null == data)
                {
                    continue;
                }

                if (null != data.lightmapColor || null != data.lightmapDir)
                {
                    var item = new Item {
                        renderer = renderer, color = data.lightmapColor, dir = data.lightmapDir
                    };
                    if (null == dep)
                    {
                        dep = new ResDepLightMap();
                    }
                    dep._items.Add(item);
                }
            }

            return(dep);
        }
示例#2
0
        /// <summary>
        /// 收集依赖
        /// </summary>
        public static void CollectRendererDependencies(GameObject go, bool bCollectChildren, List <ResDepBase> list, GameObject refObject = null, bool bCollectLightmap = true)
        {
            // 模型
            {
                MeshFilter meshfilter = null;
                if (refObject != null)
                {
                    meshfilter = refObject.GetComponent <MeshFilter>();
                }
                var dep = ResDepMesh.CollectDependencies(go, bCollectChildren, meshfilter);
                if (null != dep)
                {
                    list.Add(dep);
                }
            }

            // 蒙皮
            {
                var dep = ResDepSkinnedMesh.CollectDependencies(go, bCollectChildren);
                if (null != dep)
                {
                    list.Add(dep);
                }
            }

            // 贴图
            {
                var dep = ResDepTexture.CollectDependencies(go, bCollectChildren);
                if (null != dep)
                {
                    list.Add(dep);
                }
            }

            // Lightmap
            if (bCollectLightmap)
            {
                var dep = ResDepLightMap.CollectDependencies(refObject ?? go, bCollectChildren);
                if (null != dep)
                {
                    list.Add(dep);
                }
            }
        }