Exemplo n.º 1
0
        /// <summary>
        /// Gets the mesh.
        /// </summary>
        /// <param name="prefab">The prefab.</param>
        /// <returns>
        /// The mesh.
        /// </returns>
        protected override Mesh GetMainMesh(PrefabInfo prefab)
        {
            try
            {
                if ((UnityEngine.Object)((BuildingInfo)prefab).m_mesh != (UnityEngine.Object)null)
                {
                    return(((BuildingInfo)prefab).m_mesh);
                }

                if ((UnityEngine.Object)((BuildingInfo)prefab).m_overrideMainMesh != (UnityEngine.Object)null)
                {
                    return(((BuildingInfo)prefab).m_overrideMainMesh);
                }

                MeshFilter filter = prefab.GetComponent <MeshFilter>();
                if ((UnityEngine.Object)filter != (UnityEngine.Object)null &&
                    (UnityEngine.Object)filter.sharedMesh != (UnityEngine.Object)null)
                {
                    return(filter.sharedMesh);
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the texture.
        /// </summary>
        /// <param name="prefab">The prefab.</param>
        /// <param name="material">The material.</param>
        /// <returns>
        /// The texture.
        /// </returns>
        protected static Texture GetTextureWithFallback(PrefabInfo prefab, Material material)
        {
            if ((UnityEngine.Object)material != (UnityEngine.Object)null &&
                (UnityEngine.Object)material.mainTexture != (UnityEngine.Object)null)
            {
                return(material.mainTexture);
            }

            if ((UnityEngine.Object)prefab == (UnityEngine.Object)null)
            {
                return(null);
            }

            try
            {
                Renderer renderer = prefab.GetComponent <Renderer>();
                if ((UnityEngine.Object)renderer != (UnityEngine.Object)null &&
                    (UnityEngine.Object)renderer.sharedMaterial != (UnityEngine.Object)null &&
                    (UnityEngine.Object)renderer.sharedMaterial.mainTexture != (UnityEngine.Object)null)
                {
                    return(renderer.sharedMaterial.mainTexture);
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the texture.
        /// </summary>
        /// <param name="prefab">The prefab.</param>
        /// <returns>
        /// The texture.
        /// </returns>
        protected override Texture GetMainTexture(PrefabInfo prefab)
        {
            try
            {
                if ((UnityEngine.Object)((BuildingInfo)prefab).m_material != (UnityEngine.Object)null &&
                    (UnityEngine.Object)((BuildingInfo)prefab).m_material.mainTexture != (UnityEngine.Object)null)
                {
                    return(((BuildingInfo)prefab).m_material.mainTexture);
                }

                if ((UnityEngine.Object)((BuildingInfo)prefab).m_overrideMainRenderer != (UnityEngine.Object)null &&
                    (UnityEngine.Object)((BuildingInfo)prefab).m_overrideMainRenderer.sharedMaterial != (UnityEngine.Object)null &&
                    (UnityEngine.Object)((BuildingInfo)prefab).m_overrideMainRenderer.sharedMaterial.mainTexture != (UnityEngine.Object)null)
                {
                    return(((BuildingInfo)prefab).m_overrideMainRenderer.sharedMaterial.mainTexture);
                }

                Renderer renderer = prefab.GetComponent <Renderer>();
                if ((UnityEngine.Object)renderer != (UnityEngine.Object)null &&
                    (UnityEngine.Object)renderer.sharedMaterial != (UnityEngine.Object)null &&
                    (UnityEngine.Object)renderer.sharedMaterial.mainTexture != (UnityEngine.Object)null)
                {
                    return(renderer.sharedMaterial.mainTexture);
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the mesh.
        /// </summary>
        /// <param name="prefab">The prefab.</param>
        /// <param name="mesh">The mesh.</param>
        /// <returns>
        /// The mesh.
        /// </returns>
        protected static Mesh GetMeshWithFallback(PrefabInfo prefab, Mesh mesh)
        {
            if ((UnityEngine.Object)mesh != (UnityEngine.Object)null)
            {
                return(mesh);
            }

            try
            {
                MeshFilter filter = prefab.GetComponent <MeshFilter>();
                if ((UnityEngine.Object)filter != (UnityEngine.Object)null &&
                    (UnityEngine.Object)filter.sharedMesh != (UnityEngine.Object)null)
                {
                    return(filter.sharedMesh);
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }