ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 10 Sep 2017 03:39 PM |
| Is there a way to preload assets without having to list them? I've got too many texures and meshes in workspace and decals in gui's to be going through everything to list them in one script for preloading. |
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
| |
|
s3vvy
|
  |
| Joined: 24 Feb 2011 |
| Total Posts: 983 |
|
|
| 10 Sep 2017 04:54 PM |
*inserts very short phrase about recursive function that the OP will have to research for a couple hours in order to understand what i said*
Subscribe for scripting tutorials and more videos! www.youtube.com/c/SPiNClan |
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
| |
|
|
| 11 Sep 2017 05:47 PM |
| ContentProvider:PreloadAsync() |
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 06:56 PM |
| Basically the same thing since I'll have to list all the meshes in the game and same with gui objects. But thanks. |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2017 06:59 PM |
| even if you dont preload anything, can't you just yield until contentloadqueue or whatever is 0? preloading would be a dumb thing to do, especially if a user is on mobile, using data and isn't even required to preload all of the assets right away. |
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 07:14 PM |
| That wont work with guis since any gui object not currently visible wont be loaded when you yield requestqueuesize to be 0. only whats visible will be loaded so if i have a block that shows a gui when touched it wouldnt have been loaded. I need a way to load everything when the player joins so nothing is missing when something needs to be shown. |
|
|
| Report Abuse |
|
|
| |
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 07:19 PM |
| Just said that wont really work because I still have to list everything so it'll be the same as listing all the asset id's. I'm wondering if there is a way to load everything without having to list stuff because I have too many textures, meshes, and gui objects with decals. It'll take couple hours to get everything and make a list to Preload. If anyone knows a way to do this then be sure to let me know. If not then Ill have no choice but to list everything for preloading. |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2017 07:20 PM |
| that wont be the same as listing all the asset ids at all, lol. |
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 07:30 PM |
| Kinda is since you have to list all the objects with the texture/decals you want to preload. |
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
| |
|
|
| 11 Sep 2017 09:09 PM |
How the hell are you going to preload something if you don't have a reference to what you want to preload?
|
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 09:18 PM |
| You clearly don't understand what I'm asking. |
|
|
| Report Abuse |
|
|
|
| 11 Sep 2017 09:19 PM |
I clearly don't, and I currently would be typing a solution to your problem if you would have elaborated.
|
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 10:09 PM |
| Said it twice or three times. I'm not trying to list everything in my game to preload. I just want to know if theres a way to preload every asset in the game or at least most without having to list them and use preload or preloadasync. Don't see how I can make it any more clearer. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 11 Sep 2017 10:25 PM |
Like that one guy said, use recursive functions. Here's what I use to preload images on the client. You should be able to edit it to use for your situation
local ContentProvider = game:GetService("ContentProvider") local assets = {} function SearchForAssets(scope) for _, i in pairs (scope:GetChildren()) do if i:IsA('ImageLabel') then table.insert(assets, i.Image) end if i:IsA('ImageButton') then table.insert(assets, i.Image) end if #i:GetChildren() > 0 then SearchForAssets(i) end end end SearchForAssets(script.Parent) for _, i in pairs (assets) do ContentProvider:Preload(i) end repeat wait(1/10) until ContentProvider.RequestQueueSize == 0 print("Assets Loaded!")
|
|
|
| Report Abuse |
|
|
ReaperEVO
|
  |
| Joined: 24 Nov 2016 |
| Total Posts: 54 |
|
|
| 11 Sep 2017 10:59 PM |
| Good script i suppose but I also have imagelabels inside of other imagelabels so this won't do. Thanks for trying tho. I'll just have to list the assets then to my needs. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 11 Sep 2017 11:46 PM |
| itll still work if you change some things a bit. its not going to work perfectly for your situation since the script was made for my stuff |
|
|
| Report Abuse |
|
|
s3vvy
|
  |
| Joined: 24 Feb 2011 |
| Total Posts: 983 |
|
|
| 12 Sep 2017 07:35 PM |
I can see where you're having trouble with.
You don't exactly know how Lua terminology and processes work, and that's okay.
But when multiple people offer you the same solution, you should probably stop arguing with them, and maybe think for a second, "I may not know as much Lua as they do."
Trust me, I used to be like you, a little anarchist.
Proficient Lua code is BASED off of "lists", believe it or not.
You complimented the script that he provided you, even though it used "lists" anyways.
There are only two functions you have available to you: PreloadAsync() and Preload()
PreloadAsync() requires a "list", pauses the script, preloads every instance in that list and then resumes whatever is after. Preload() needs a single argument which is a content ID, aka "asset id link" to describe it, and does not pause to script. Instead, it adds the ID to a queue, and everything in that queue is loaded in order of chronological addition. Even though Preload() can only add one item to load to that queue every time the function is ran, you will have to run it multiple times to run multiple items.
Whether you like it or not, you are going to have to use "lists" if you want to load more than 1 object.
Now, "lists" as you call them, aren't always manually created. Sometimes they are created by functions as well. In his code, he creates a list and adds data to it.
"local assets = {}"
The data isn't manually added one by one, but is developed by a "recursive function", as other people mentioned before.
You said that you didn't want to "list" every instance in the game, yet you said the following right after:
"I just want to know if theres a way to preload every asset in the game or at least most without having to list them"
Now that can confuse a lot of people, but I understand what you're saying.
Next time, don't think that everything you know is correct and that others are wrong. You may have some slight errors in terminology which can guide your forum post to an argument.
idk why i wasted time explaining this.. something about you ticked me off
Subscribe for scripting tutorials and more videos! www.youtube.com/c/SPiNClan |
|
|
| Report Abuse |
|
|
rihlsul
|
  |
| Joined: 09 Dec 2015 |
| Total Posts: 13 |
|
|
| 11 Oct 2017 02:13 PM |
Apologies for the Necropost, but this is one of the threads that comes up when searching to learn about Preloading Assets.
Not sure if it was true when this thread was discussed, but the wiki points out that with ContentProvider:PreloadAsync():
--When the function is called, the engine will go through all of the instances in the passed in array (and all of the descendants of the passed in instances)--
So, for anyone else that comes here as I did, you could point this process at your Gui's root and let it sort it out for you.
Also, s3vvy, thank you for explanations - you don't just help the person who asked, but anyone who comes along later, so it's appreciated. |
|
|
| Report Abuse |
|
|