public static T getComponentContext <T>(Transform tr, string endName) where T : Component { tr = HalperTransform.findChild(tr, endName); if (tr == null) { return(null); } return(tr.GetComponent <T>()); }
static public void forceValue(Transform tr, string trName, string floatName, float val, int matIdx = 0) { if (!Application.isPlaying) { Transform halo = tr; if (trName.Length > 0) { halo = HalperTransform.findChild(tr, trName); } Renderer render = halo.GetComponentInChildren <Renderer>(); Material mat = matIdx > 0 ? render.sharedMaterials[matIdx] : render.sharedMaterial; mat.SetFloat(floatName, val); //Debug.Log(mat.name + " , " + floatName + " , " + val); return; } }