Jump to content

Failed to load Prefab on Published Game


Hodor88
 Share

Recommended Posts

Hi there,

 

having to trouble with my Scripts. I'm using an Spawn Script for Zombies. This works finde in Editor Mode and Debug. No Problems so far.

 

After Publishing the Game. On first spawn i get following Error Message:

 

Error: Failed to read file "C:/Users/Marco/Desktop/ZombieZ-Starter/GameStarter/G

ameStarter/bin/Debug/Data/Horde/offshore/AddOns/Zombie Character Pack/zombie1.pfb".

Error: Failed to load prefab "C:/Users/Marco/Desktop/ZombieZ-Starter/GameStarter

/GameStarter/bin/Debug/Data/Horde/offshore/AddOns/Zombie Character Pack/zombie1.pfb".

Lua Error: [string "C:/Users/Marco/Desktop/ZombieZ-Starter/GameStarter/GameStart

er/bin/Debug/Data/Horde/offshore/scripts/gamecontroller.lua"]:99: attempt to index local 'zombie' (a nil value)

 

I guess the problem is that the script wants to load the file from this path:

 

C:/Users/Marco/Desktop/ZombieZ-Starter/GameStarter

/GameStarter/bin/Debug/Data/Horde/offshore/AddOns/Zombie Character Pack/zombie1.pfb

 

This can not work, because all of the Game Data is zipped in the Data directory.

 

Any idea how to fix this issue?

  • Upvote 1
Link to comment
Share on other sites

If you are using Prefab:Load() and passing in a relative path it should be fine.

 

One thing we run into is when publishing make sure to do ALL files not just used files. If your prefab is NOT in the editor and ONLY loaded in code then the publish won't include it in the build because I don't think the publisher goes through the code to see what's used, but instead just looks at the map file to see what's used and what to include in the zip files.

 

Your other way around this is to place the prefab in the scene somewhere as a precache. Just disable it.

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...