- Home /
Resources.Load Problem
I have an empty game object.I added ellipsoid particle emitter to it.I just want to change particles' material with script.For that i wrote this script and added to empty game object:
public class SPHUnity : MonoBehaviour {
private ParticleRenderer prenderer;
private Material waterMat;
public void Start() {
prenderer = (ParticleRenderer) gameObject.AddComponent(typeof(ParticleRenderer));
waterMat = (Material) Resources.Load("Water Splash1");
prenderer.material = waterMat;
}
}
But still particles have default material.Water Splash1 material is in Standart Assets/Particles/Sources/Materials. What am i doing wrong? Thanks for help.
Answer by Tim-Michels · Jul 11, 2012 at 11:37 AM
Resources.Load will load assets from the folder Assets/Resources
Therefore, the asset you're loading should be inside that folder (or subfolder of Resources)
There's also a Resources.LoadAssetAtPath function, but that only works in editor.
Your answer
![](https://koobas.hobune.stream/wayback/20220613074030im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to add material component to an Animate GUI script 1 Answer
Is it possible to create a Material _asset_ from a script? 3 Answers
Assigning meshes & materials from Assets, how? 1 Answer
Creating a script instance from an asset 1 Answer
Cannot assign assets to variables via inspector: NullReferenceException 3 Answers