Hi everyone, i’m trying to load some assets in a specific moment in my game wit a script (below). When I start the game everyting’s ok, but when I try to build it Unity returns me this error : ‘unityengine.resources does not contain a definition for LoadAssetAtPath’ and below : ‘Error building Player because scripts had compiler error’.
Have you any idea ? Thank you very much.
[…]
if (prob_bonus_exit[(multiplier - 1), randm_bonus] == 1) // se è un bonus
{
int rand_val_bonus = Random.Range(0, 24);
GameObject clone = Instantiate(BonusSphere, new Vector3(positions[randomrr], heights[(multiplier - 1), randomh], -1), Quaternion.identity) as GameObject;
clone.transform.SetParent(gameObject.transform);
clone.GetComponent<Rigidbody2D>().gravityScale = 0.7f * Force;
clone.name = "b_bonus_" + probability_bonus[rand_val_bonus];
clone.GetComponent<SpriteRenderer>().sprite = (Sprite)Resources.LoadAssetAtPath("Assets/Imgs/MainScene/Meteorites/FallingSphere" + probability_bonus[rand_val_bonus] + ".png", typeof(Sprite));