- Home /
Import assets through script
I work on project where I would like to load asset "particles". Normally I would do it by clicking on GUI, but I need it loaded by script. I tried this, but it does not work.
using UnityEngine;
using System.Collections;
using UnityEditor;
public class importAsset : MonoBehaviour {
// Use this for initialization
void Start()
{
Debug.Log(Application.dataPath.ToString());
string appPath = Application.dataPath + "/Particles";
appPath = appPath.Replace('\\', '/');
UnityEditor.AssetDatabase.ImportPackage(appPath, true);
AssetDatabase.Refresh();
}
// Update is called once per frame
void Update () {
}
}
I put this script to Editor directory in asset directory of may project, but still no change. No assets loaded.
Thanks for any idea.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613132227im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Script to load a text file gives error. 1 Answer
Loading a level. (Few questions) 1 Answer
Check if all Materials are generated? 0 Answers
Accessing an already loaded Asset Bundle 1 Answer
random level loader? 1 Answer