title: Create material from code and assign it to an object
body: <p>I am very new to Unity3d. I have a prefab which contains 6 quads making it a cube. I want to add image textures to different faces of cube.
  I am getting images from a web service, so I have to add or change material in the script.
  The problem I am facing is, I am not able to find material property in gameObject.</p>
  <p>I have tried below code:</p>
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class shelfRuntime : MonoBehaviour {
      public GameObject bottle;
      public GameObject newBottle;
      // Use this for initialization
      void Start () {
     
              iterateChildren(newBottle.transform.root);
          
          GameObject rocketClone = (GameObject)Instantiate(bottle, bottle.transform.position, bottle.transform.rotation);
          rocketClone.transform.localScale += new Vector3(1, 1, 1);
          GameObject newBottleInMaking = (GameObject)Instantiate(newBottle, newBottle.transform.position, newBottle.transform.rotation);
  
          Transform[] allChildren = newBottleInMaking.GetComponentsInChildren&lt;Transform&gt;();
          foreach (Transform child in allChildren)
          {
              // do whatever with child transform here
          }
      }
      void iterateChildren(Transform trans)
      {
          Debug.Log(trans.name);
          if (trans.name == &quot;Back&quot;) {
              var ting = trans.gameObject.GetComponent&lt;Renderer&gt;();
          //   trans.renderer.material  // there is no material property here 
          }
  
          // Do whatever logic you want on child objects here
          if (trans.childCount == 0) return;
  
          foreach (Transform tran in trans)
          {
              iterateChildren(tran);
          }
      }
  
      // Update is called once per frame
      void Update () {
      
      }
  }
  </code></pre>
  <p>How to set material to quads? There are 6 quads inside my prefab.</p>