Ejemplo n.º 1
0
        /// <summary>
        /// 收集依赖
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public static ResDepTexture CollectDependencies(Material m)
        {
            ResDepTexture dep = null;

            EditorUtil.VisitShaderProperties(m, (n) =>
            {
                CollectDependencies(ref dep, null, m, n);
            });

            return(dep);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 收集依赖
        /// </summary>
        /// <param name="go"></param>
        /// <returns></returns>
        public static ResDepTexture CollectDependencies(GameObject go, bool bCollectChildren)
        {
            ResDepTexture dep = null;

            EditorUtil.VisitShaderProperties(go, bCollectChildren, (m, n) =>
            {
                CollectDependencies(ref dep, go, m, n);
            });

            return(dep);
        }
Ejemplo n.º 3
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);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 收集依赖
        /// </summary>
        /// <param name="dep"></param>
        /// <param name="m"></param>
        /// <param name="shaderPropIndex"></param>
        static void CollectDependencies(ref ResDepTexture dep, GameObject go, Material m, int shaderPropIndex)
        {
            var pt = UnityEditor.ShaderUtil.GetPropertyType(m.shader, shaderPropIndex);

            if (UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv != pt)
            {
                return;
            }

            // 获取贴图
            var propName = UnityEditor.ShaderUtil.GetPropertyName(m.shader, shaderPropIndex);
            var propId   = Shader.PropertyToID(propName);
            var tex      = m.GetTexture(propId);

            // 没有贴图
            if (null == tex)
            {
                return;
            }

            if (null == dep)
            {
                dep = new ResDepTexture();
            }

            // 生成信息
            var item = new Item();

            item.go       = go;
            item.mat      = m;
            item.propName = propName;
            item.texture  = tex;
            dep._items.Add(item);

            // 备份材质
            AssetsBackuper.inst.Backup(item.mat);
        }