TreeEditor.TreeGroup.GetMaterialIndex C# (CSharp) Method

GetMaterialIndex() protected static method

protected static GetMaterialIndex ( Material m, List materials, bool tileV ) : int
m UnityEngine.Material
materials List
tileV bool
return int
        protected static int GetMaterialIndex(Material m, List<TreeMaterial> materials, bool tileV)
        {
            for (int i = 0; i < materials.Count; i++)
            {
                if (materials[i].material == m)
                {
                    TreeMaterial local1 = materials[i];
                    local1.tileV |= tileV;
                    return i;
                }
            }
            TreeMaterial item = new TreeMaterial {
                material = m,
                tileV = tileV
            };
            materials.Add(item);
            return (materials.Count - 1);
        }

Usage Example

Example #1
0
 public override void UpdateMesh(List <TreeMaterial> materials, List <TreeVertex> verts, List <TreeTriangle> tris, List <TreeAOSphere> aoSpheres, int buildFlags, float adaptiveQuality, float aoDensity)
 {
     if (this.geometryMode == 4)
     {
         if (this.instanceMesh != null)
         {
             TreeGroupLeaf.cloneMeshFilter = this.instanceMesh.GetComponent <MeshFilter>();
             if (TreeGroupLeaf.cloneMeshFilter != null)
             {
                 TreeGroupLeaf.cloneMesh = TreeGroupLeaf.cloneMeshFilter.sharedMesh;
                 if (TreeGroupLeaf.cloneMesh != null)
                 {
                     Vector3 extents = TreeGroupLeaf.cloneMesh.bounds.extents;
                     float   num     = Mathf.Max(extents.x, extents.z) * 0.5f;
                     TreeGroupLeaf.cloneVerts    = TreeGroupLeaf.cloneMesh.vertices;
                     TreeGroupLeaf.cloneNormals  = TreeGroupLeaf.cloneMesh.normals;
                     TreeGroupLeaf.cloneUVs      = TreeGroupLeaf.cloneMesh.uv;
                     TreeGroupLeaf.cloneTangents = TreeGroupLeaf.cloneMesh.tangents;
                     for (int i = 0; i < TreeGroupLeaf.cloneVerts.Length; i++)
                     {
                         Vector3[] expr_D8_cp_0 = TreeGroupLeaf.cloneVerts;
                         int       expr_D8_cp_1 = i;
                         expr_D8_cp_0[expr_D8_cp_1].x = expr_D8_cp_0[expr_D8_cp_1].x / num;
                         Vector3[] expr_F0_cp_0 = TreeGroupLeaf.cloneVerts;
                         int       expr_F0_cp_1 = i;
                         expr_F0_cp_0[expr_F0_cp_1].y = expr_F0_cp_0[expr_F0_cp_1].y / num;
                         Vector3[] expr_108_cp_0 = TreeGroupLeaf.cloneVerts;
                         int       expr_108_cp_1 = i;
                         expr_108_cp_0[expr_108_cp_1].z = expr_108_cp_0[expr_108_cp_1].z / num;
                     }
                 }
             }
             if (this.instanceMesh.GetComponent <Renderer>() != null)
             {
                 Material[] sharedMaterials = this.instanceMesh.GetComponent <Renderer>().sharedMaterials;
                 for (int j = 0; j < sharedMaterials.Length; j++)
                 {
                     TreeGroup.GetMaterialIndex(sharedMaterials[j], materials, false);
                 }
             }
         }
     }
     else
     {
         TreeGroup.GetMaterialIndex(this.materialLeaf, materials, false);
     }
     for (int k = 0; k < this.nodes.Count; k++)
     {
         this.UpdateNodeMesh(this.nodes[k], materials, verts, tris, aoSpheres, buildFlags, adaptiveQuality, aoDensity);
     }
     TreeGroupLeaf.cloneMesh       = null;
     TreeGroupLeaf.cloneMeshFilter = null;
     TreeGroupLeaf.cloneVerts      = null;
     TreeGroupLeaf.cloneNormals    = null;
     TreeGroupLeaf.cloneUVs        = null;
     TreeGroupLeaf.cloneTangents   = null;
     base.UpdateMesh(materials, verts, tris, aoSpheres, buildFlags, adaptiveQuality, aoDensity);
 }
All Usage Examples Of TreeEditor.TreeGroup::GetMaterialIndex