Hey Guys
I have a problem:
I wanna instantiate an ParticleSystem, which is in a folder in my project. I wanna load this ParticleSystem per path.
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour{
private GameObject prefab;
void Start(){
prefab = Resources.LoadAssetAtPath("Assets/Artwork/ParticleSystem.prefab",
typeof(GameObject)) as GameObject;
Instantiate(prefab,prefab.transform.position,prefab.transform.rotation);
}
}
Ok now i can’t Instantiate because the “prefab” is = null. (I think it doesn’t find the object)
I couldn’t upload an image of the project folder so I describe:
Theres an folder Assets with an subfolder Artwork. In the artwork folder is an Empty object Particlesystem which contains the particlesystem.
Beside the Assets folder, there is an Scripts folder with this example script.
Thanks for your help!
This is not a solution. What if you were to save changes and close unity before you did all the undos? Only solutions are to be marked as correct answers. If you don't find a solution in one of the answers someone has given, simply close the question and give a reason for closing.
– clunk47