Preload (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Legend26 Changed to use local template. |
>Quenty No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 40: | Line 40: | ||
This way, it ads NumOf each time it uploads a new thing, then calculates how the loading bar should look. The LoadingBar would be sized so it that it would look like the full bar, then the actual 'Bar' would move along with the amount that was done. | This way, it ads NumOf each time it uploads a new thing, then calculates how the loading bar should look. The LoadingBar would be sized so it that it would look like the full bar, then the actual 'Bar' would move along with the amount that was done. | ||
To learn more, see the [[GUI]] section. | |||
}} | }} | ||
[[Category:Methods]] | [[Category:Methods]] |
Latest revision as of 22:21, 20 March 2012
Local: This item should be used with a LocalScript in order to work as expected in online mode.
Preload( string asset ) | |
Returns | nil |
Description: | Downloads the requested asset to the client and prepares it for use. |
Member of: | ContentProvider |
Example
Can be used to load an asset (common assets loaded are images) so it doesn't take any time when shown as textures or decals.
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=2453543")
Example
A fast way to load assets is to put them into a table, then loop through the table, and load them.
Assets = {2253543,2434541,5133543,2423433,41143243,2453865,21433365,2154549} for i=1, #Assets do Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..Assets[i]) end
The script will wait until the assets are loaded, then go on. Thus, you can make loading bars using GUIs by changing the scale of a GUI from 0 to 1.
Assets = {2253543,2434541,5133543,2423433,41143243,2453865,21433365,2154549} NumOf = 0 for i=1, #Assets do Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..Assets[i]) NumOf = NumOf + 1 script.Parent.GUI.LoadingBar.Bar.Size = UDim2.new(NumOf/#Assets, 0, 1, 0) end
This way, it ads NumOf each time it uploads a new thing, then calculates how the loading bar should look. The LoadingBar would be sized so it that it would look like the full bar, then the actual 'Bar' would move along with the amount that was done. To learn more, see the GUI section.