- Home /
Cannot find 3D Prefab after doing a build.
Steps to Duplicate Issue: 1. I have an FBX object that I broke up into 30 FBX objects.
2. I created 30 Prefab objects from those 30 FBX objects.
3. I built a script to load all of the prefabs names into the DropDownList.
4. Then a user clicks on a Prefab name in the DropDownList and then I instantiate and load the Prefab.
It works great in the Unity editor because I use UnityEditor calls(AssetDatabase...).
When I do a build I cannot use UnityEditor calls. This line causes my App not to build: prefab = AssetDatabase.LoadAssetAtPath(myPath, typeof(UnityEngine.Object)); The error states to not use UnityEditor inside the app. Which makes sense.
If in my App I put the path to the 30 Prefab objects in my build directory it works fine.
QUESTIONS:
How do I find the Prefab objects after the build? It seems my objects are in a resources.assets file.
Are my Prefabs objects in the resources directory of my build within an assets file?
Can I grab them by name?
Code snippets:
LOADING DropDownList
FBXPrefabInFolder = new List<string>();
FBXPrefabFileSize = new List<long>();
string strdir = new DirectoryInfo(AppLevelPathPath).FullName ;
DirectoryInfo dir = new DirectoryInfo(strdir);
FileInfo[] info = dir.GetFiles("*.prefab");
foreach (FileInfo f in info)
{
if ( f.Extension == ".prefab")
{
string tempName = f.Name;
string extension = f.Extension;
string strippedName = tempName.Replace(extension, "");
FBXPrefabInFolder.Add(strippedName);
FBXPrefabFileSize.Add(f.Length);
drpPartsOnDisk.options.Add(new Dropdown.OptionData() { text = strippedName.ToString() });
}
}
LOADING PREFAB
private UnityEngine.Object prefab;
public GameObject instance;
GameObject GO;
prefab = Resources.LoadAll< UnityEngine.Object>(AppTHISISSEARCHPath + inpPartText.text);
GO = prefab as GameObject;
instance = Instantiate(GO) as GameObject;
Your answer
Follow this Question
Related Questions
Search for a prefab with certain property 2 Answers
Instantiating a prefab as a component type? 2 Answers
Instantiating prefab from another script. Error, prefab is null. 1 Answer
Instantiate an prefab as a child of the player 3 Answers
Instantiate a prefab and follow player position in runtime? 0 Answers