public static void ApplyAll(SkinnedMeshRenderer rend, InfoOnBlock info) { if (rend != null && info != null && info.Blendshapes != null) { for (int i = 0; i < info.Blendshapes.Length; i++) { rend.SetBlendShapeWeight(i, info.Blendshapes [i]); if (info.Blendshapes == null) { info.Blendshapes = new float[rend.sharedMesh.blendShapeCount]; } } } }
public static void ShowMenu(SkinnedMeshRenderer rend, InfoOnBlock info) { instance.currRend = rend; instance.currInfo = info; for (int i = 0; i < instance.transform.childCount; i++) { Destroy(instance.transform.GetChild(i).gameObject); } for (int i = 0; i < rend.sharedMesh.blendShapeCount; i++) { var go = Instantiate(instance.sliderPrefab); var sl = go.GetComponent <UnityEngine.UI.Slider> (); sl.value = rend.GetBlendShapeWeight(i); go.GetComponentInChildren <UnityEngine.UI.Text> ().text = rend.sharedMesh.GetBlendShapeName(i); var ind = i; sl.onValueChanged.AddListener(x => { instance.SetBlendshape(ind, x); }); go.transform.SetParent(instance.transform); } instance.gameObject.SetActive(true); }