In this example, we will show you how to make basic configurations for the mobile editor. The example is based on the Design Editor
, however, it is exactly the same for all the other solutions.
Configuration
All the basic configuration settings are part of the EngineConfiguration
.
license
- the license to activate the Engine with.
license = "<your license here>",
userId
- an optional unique ID tied to your application’s user. This helps us accurately calculate monthly active users (MAU). Especially useful when one person uses the app on multiple devices with a sign-in feature, ensuring they’re counted once. Providing this aids in better data accuracy. The default value isnull
.
userId = "<your unique user id>",
baseUri
- is used to initialize the engine’sbasePath
setting before the editor’sonCreate
callback is run. It is the foundational URI for constructing absolute paths from relative ones. For example, setting it to the Android assets directory allows loading resources directly from there:file:///android_asset/
. This URI enables the loading of specific scenes or assets using their relative paths. The default value is pointing at the versioned IMG.LY CDN but it should be changed in production environments.
baseUri = Uri.parse("file:///android_asset/"),
sceneUri
- the scene URI to load content within the editor. Note that this configuration is only available inEngineConfiguration.rememberFor{solution-name}
helper functions. This URI is used to load the scene inEdiorConfiguration.onCreate
, therefore, you can configure the scene you load without helper functions too: simply invokeEditorDefaults.onCreate(engine, sceneUri, eventHandler)
inEdiorConfiguration.onCreate
. By default, helper functions load the scenes that are available atEdiorConfiguration.default{solution-name}Scene
. Normally, you should not modify thesceneUri
, however, you may want to save/restore the editing progress for your customers. If that is the case, you should save the scene in one of the callbacks, then provide the URI of the newly saved scene when your customer opens the editor next time.
sceneUri = EngineConfiguration.defaultDesignSceneUri,
renderTarget
- the target which should be used by the Engine to render. The engine is able to render on both SurfaceView and TextureView. The default value isEngineRenderTarget.SURFACE_VIEW
.
renderTarget = EngineRenderTarget.SURFACE_VIEW,
Full Code
Here’s the full code:
import android.net.Uriimport androidx.compose.runtime.Composableimport androidx.navigation.NavHostControllerimport ly.img.editor.DesignEditorimport ly.img.editor.EngineConfigurationimport ly.img.editor.core.engine.EngineRenderTargetimport ly.img.editor.rememberForDesign
// Add this composable to your NavHost@Composablefun BasicEditorSolution(navController: NavHostController) { val engineConfiguration = EngineConfiguration.rememberForDesign( license = "<your license here>", userId = "<your unique user id>", baseUri = Uri.parse("file:///android_asset/"), sceneUri = EngineConfiguration.defaultDesignSceneUri, renderTarget = EngineRenderTarget.SURFACE_VIEW, ) DesignEditor(engineConfiguration = engineConfiguration) { // You can set result here navController.popBackStack() }}