Don't want or don't need to write code? Use the included components to load textures without writing any code!
Check the Customize section to override or create a new codeless component.
By default textures are loaded on Awake and always disposed on OnDestroy.
Customize
TextureLoader allows extending and customizing parts of its main functionality without having to modify the source code.
Targets
Targets are Unity components capable of rendering textures. TextureLoader can apply loaded textures to these targets through the Into(TextureTarget target) method.
Override the included targets or create your own by inheriting from the TextureTarget class or any of its subclasses:
Included targets: ARB/TextureLoader/Scripts/Targets
usingARB.TextureLoader;usingUnityEngine;publicclassMyTextureTarget:TextureTarget{ // Implement the way to get and set the texture on your target. protected override Texture CurrentTexture { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
// Use a constructor to pass the renderer you want to use as a texture target.publicMyTextureTarget(Renderer target,float fadeTime =0f): base(fadeTime) { // Your implementation. }publicoverridevoidDispose() { // Make sure to destroy any resources that are no longer needed here. }publicoverridevoidSetAlpha(float alpha) { // Implement the way to change the transparency of your renderer (if applicable). } // Fader: // Optional game object placed in front of the target renderer, used to create // a crossfade effect between the current texture and the loaded texture. // Temporarily holds the current texture and fades out revealing the new texture behind.protectedoverridevoidSetFaderAlpha(float value) { // Implement the way to change the transparency of your fader (if applicable). }protectedoverridevoidSetFaderTexture(Texture texture) { // Implement the way to set the texture of the fader (if applicable). }}
Placeholders are game objects that can be optionally displayed during a loading operation when the texture is set to load into a target.
Override the included placeholders or create your own by inheriting from the Placeholder class or any of its subclasses:
Included placeholders: ARB/TextureLoader/Scripts/Targets/Placeholders
usingARB.TextureLoader;usingUnityEngine;publicclassMyPlaceholder:Placeholder{ // Implement the way to know if your game object is active.publicoverridebool IsActive =>thrownewSystem.NotImplementedException(); // Use a constructor to pass the game object you want to use as a placeholder.publicMyPlaceholder(GameObject go) { // Your implementation. }publicoverridevoidDispose() { // Make sure to destroy any resources that are no longer needed here. }publicoverridevoidSetActive(bool value) { // Implement the way to enable/disable your game object here. }publicoverridevoidSetAlpha(float value) { // Implement the way to change the transparency of your game object (if applicable). }}
In order to use your new placeholder either override one of the included texture targets or create a new one. Here's an example overriding an existing texture target: