- Home /
loading 3d models in unity editor and in deployed app
I've created an app that make use of models that in editor I load using UnistyEditor AssetDatabase.LoadAssetAtPath. If I try to deploy it says that Unity Editor can't be used. So which is the best strategy that I should apply to load my models at run time, outside the editor? Thank you, Cheers
Daniele
Comment
Answer by ctalystnetwork · Jul 01, 2017 at 09:11 PM
Hi,
Take a look at the unity docs for loading at runtime: https://docs.unity3d.com/Manual/LoadingResourcesatRuntime.html
From the above link you could use Resources.Load() to do what your looking for:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
void Start()
{
// Instantiates a prefab named "enemy" located in any Resources
// folder in your project's Assets folder.
GameObject instance = Instantiate(Resources.Load("enemy", typeof(GameObject))) as GameObject;
}
}