public void ChangeMaterial(int index) { HatContent textFile = Resources.Load <HatContent>(m_CurrentId + "_Scriptable") as HatContent; Debug.Log(m_CurrentId + "_Scriptable"); Renderer[] a = m_CurrentHat.GetComponentsInChildren <Renderer>(); List <Material> mats = new List <Material>(); for (int i = 0; i < a.Length; i++) { for (int j = 0; j < a[i].materials.Length; j++) { mats.Add(a[i].materials[j]); } } for (int i = 0; i < mats.Count; i++) { for (int j = 0; j < textFile.hatMaterials.Count; j++) { string modelMaterialName = mats[i].name; string scriptableMaterialName = textFile.hatMaterials[j].materialName; if (modelMaterialName.Contains(scriptableMaterialName)) { // mats[i].SetTexture("_MainTex", textFile.hatMaterials[j].hatTextures[index]); } } } }
public void InstantiateHat(Object s, Object c) { if (FirebaseController.stopDownload == false) { Debug.Log("<color=blue> descargo </color>"); m_HatLoadingPanel.SetActive(false); StartCoroutine(OnViewGif()); m_HatErrorPanel.SetActive(false); //m_CurrentHat = (GameObject)Instantiate(Resources.Load(m_CurrentHatId + "/" + m_CurrentHatId)); m_CurrentHat = (GameObject)Instantiate(s); //m_CurrentHatContent = Resources.Load<HatContent>(m_CurrentHatId + "/" + m_CurrentHatId + "_content") as HatContent; m_CurrentHatContent = (HatContent)c; m_CurrentId = m_CurrentHatId; m_HatPosition = FindObjectOfType <Object3D_Complete>().m_hatPosition; m_CurrentHat.transform.parent = m_HatPosition; m_CurrentHat.transform.localPosition = Vector3.zero; m_CurrentHat.transform.localRotation = Quaternion.identity; m_CurrentHat.transform.localScale = Vector3.one; } // LoadMaterialsforBundle(m_CurrentHat, m_CurrentHatContent, m_CurrentId, m_CurrentHatColor); //Loading Panel // m_HatLoadingPanel.SetActive(false); }
public void LoadMaterialsforBundle(GameObject hatbundle, HatContent hatContent, string hatId, string hatColor) { Debug.Log(hatColor); Renderer[] rendererChilds = hatbundle.GetComponentsInChildren <Renderer>(); for (int j = 0; j < rendererChilds.Length; j++) { for (int i = 0; i < hatContent.hatMaterials[0].hatMaterials.Count; i++) { rendererChilds[i].material = hatContent.hatMaterials[0].hatMaterials[i]; } } }