Mscr:Assets.Asset: Difference between revisions
Created page with "{{note|todo|TO BE COMPLETED}} = Static Initialization = Static initialization of Assets is an important topic to understand. Due to the fact that {{code|Assets.GetAsset}} can be called during static initialization, Assets loaded from disk are loaded '''before''' the general script static initialization. For that reason, it's important to not rely on any script-defined statics to be available during static initialization and construction of any Asset-derived classes, as..." |
mNo edit summary |
||
| Line 1: | Line 1: | ||
{{note|todo|TO BE COMPLETED}} | {{note|todo|TO BE COMPLETED}} | ||
= Public Methods = | |||
== Init == | |||
<syntaxhighlight lang="cs">virtual void Init()</syntaxhighlight> | |||
Called during initialization of the Asset, either when created or when loaded from disk. Note that this is called after static initialization, but before Assets are loaded. It's recommended to call anything in here that relies on the contents of static variables, see [[#Static Initialization]]. | |||
{{note|todo|Init is not currently implemented}} | |||
= Static Initialization = | = Static Initialization = | ||
Static initialization of Assets is an important topic to understand. Due to the fact that {{code|Assets.GetAsset}} can be called during static initialization, Assets loaded from disk are loaded '''before''' the general script static initialization. For that reason, it's important to not rely on any script-defined statics to be available during static initialization and construction of any Asset-derived classes, as all static values will be zero. | Static initialization of Assets is an important topic to understand. Due to the fact that {{code|Assets.GetAsset}} can be called during static initialization, Assets loaded from disk are loaded '''before''' the general script static initialization. For that reason, it's important to not rely on any script-defined statics to be available during static initialization and construction of any Asset-derived classes, as all static values will be zero. | ||
If you really need to initialize something using a static, it's recommended to put it in the [[#Init|Init]]() method. | |||
{{note|todo|Defer all actual Asset data loads until after creation, and call {{code|Asset.Init()}} ''before'' loading in the data.}} | {{note|todo|Defer all actual Asset data loads until after creation, and call {{code|Asset.Init()}} ''before'' loading in the data.}} | ||
Revision as of 07:13, 27 August 2026
Public Methods
Init
virtual void Init()
Called during initialization of the Asset, either when created or when loaded from disk. Note that this is called after static initialization, but before Assets are loaded. It's recommended to call anything in here that relies on the contents of static variables, see #Static Initialization.
Static Initialization
Static initialization of Assets is an important topic to understand. Due to the fact that Assets.GetAsset can be called during static initialization, Assets loaded from disk are loaded before the general script static initialization. For that reason, it's important to not rely on any script-defined statics to be available during static initialization and construction of any Asset-derived classes, as all static values will be zero.
If you really need to initialize something using a static, it's recommended to put it in the Init() method.
Asset.Init() before loading in the data.