Addressables Source Generator
Denis535
$0.0
(no ratings)
Date |
Price |
---|---|
日期和时间 |
价钱($) |
03/09(2024) |
0.0 |
11/06(2024) |
0.0 |
Jump AssetStore
It gives you the ability to easy reference assets with compile-time checking. Like: "R.MyProject.Scenes.MainScene".# OverviewThis package is addition to Addressables giving you the ability to reference assets in a very convenient way with compile-time checking. Like: "R.MyProject.Scenes.MainScene".# How to use it## How to generate source codeYou should create the 'AddressablesSourceGenerator' asset and press the 'Generate' button in the inspector. Or you can do it manually:```var settings = AddressableAssetSettingsDefaultObject.Settings;new ResourcesSourceGenerator().Generate( settings, "Assets/UnityEngine.AddressableAssets/R.cs", "UnityEngine.AddressableAssets", "R" );new LabelsSourceGenerator().Generate( settings, "Assets/UnityEngine.AddressableAssets/L.cs", "UnityEngine.AddressableAssets", "L" );```It will generate the 'R' and 'L' classes:```namespace UnityEngine.AddressableAssets {public static class @R {public static class @MyProject {public static class @Scenes {public const string @MainScene = "MyProject/Scenes/MainScene.unity";public const string @GameScene = "MyProject/Scenes/GameScene.unity";}}}public static class @L {public const string @default = "default";public const string @Scene = "scene";}}```## How to use generated source codeNow you can referencing your assets very easily:```var address = R.MyProject.Scenes.MainScene;var label = L.Scene;```# Reference## AddressablesSourceGeneratorvoid Generate()## ResourcesSourceGeneratorvoid Generate(AddressableAssetSettings settings, string path, string @namespace, string name)## LabelsSourceGeneratorvoid Generate(AddressableAssetSettings settings, string path, string @namespace, string name)# Linkshttps://denis535.github.ioThe source code generator.The source code with all asset addresses and labels.Compiler-time checking.Easy referencing the addressable assets.Easy referencing the addressable labels.