Attributes Implementation

With Luna Playground, anyone will be able to create unlimted playable ad variations in a matter of seconds without having to touch your code or rebuild the project.

When preparing your game in Unity, you are able to apply the LunaPlaygroundField or LunaPlaygroundAsset attribute to any serializable field (i.e. public fields of MonoBehaviours and ScriptableObjects or fields marked with SerializeField attribute) and it will be surfaced in the playable editor in Luna Playground.

Attribute Types

LunaPlaygroundField

This is the most common Luna attribute, and should be used for the scriptable game objects you wish to edit from Luna Playground. For example, you will want to use this for all text and colors for the end card.

  • Supported Types
    • String
    • Integer
    • Float
    • Color
    • Vector2
    • Vector3
    • Vector4
    • Enums
    • Bool

LunaPlaygroundAsset

This should be used when you want to create multiple variations of your ads with different textures or videos, but don't want to increase the overall build size. When using this attribute, you will be able to upload images or videos directly in Luna Playground. For example, you may wish to change the game icon for your end card.

LunaPlaygroundAssets must be assigned a default value in Unity. Assets without a default value will not be shown in Luna Playground.
  • Supported Types
    • Image or texture (.png, .jpg, .jpeg)
      • In Unity, please use Texture or Texture2D
    • Video (.mp4)
      • In Unity, please use Video.VideoClip
    • Font (.ttf)
      • In Unity, please use UnityEngine.Font
Please keep in mind that due to technical specifics of implementation, all instances of a class with variation-controlled fields will receive an updated value. That is fine for Scriptable Objects (because those normally exist as a single instance anyway), but might be a surprise for Mono Behaviours.

Implementation

For each Playground Field, you can specify the title, group and field order.

[LunaPlaygroundField("Field title", 0, "Group title")]

  • Field title: The name of the field in Playground i.e. "End card title"
  • Field order: The order of the field in Playground
  • Field section: The name of the group to which the field belongs i.e. "End Card"
Field title is required. Field section and Field order are optional.

Example

[Header("Playable Ad Settings")]
[SerializeField]
[LunaPlaygroundField("Color of the player", 0, "Player Controls")]
private Color playerColor = Color.blue;
[SerializeField]
[LunaPlaygroundField("Speed of the player", 1, "Player Controls")]
private float playerSpeed = 1f;
[SerializeField]
[LunaPlaygroundField("Number of levels", 2, "Game Controls")]
private int gameLevels = 1;
[SerializeField]
[LunaPlaygroundField("Relative game difficulty", 3, "Game Controls")]
private int gameDifficulty = 3;
[SerializeField]
[LunaPlaygroundAsset("Game Icon", 4, "End Card")]
private Texture gameIconTexture;
[SerializeField]
[LunaPlaygroundAsset("Video Clip", 5, "End Card")]
private VideoClip videoClip;

Playground Sections

The LunaPlaygroundSection attribute can be applied to a class in order to add all Luna Fields and Assets into the same Playground section.

The Playground section will be overridden by the optional parameter, "FieldSection", of a LunaPlaygroundField or LunaPlaygroundAsset attribute.

For example:

[LunaPlaygroundSection("Player Controls", 0)]
public class Player : MonoBehaviour {
[SerializeField]
[LunaPlaygroundField("Color of the player", 0)]
private Color playerColor = Color.blue;
[SerializeField]
[LunaPlaygroundAsset("Speed of the player", 1)
private float playerSpeed = 1f;
}

Recommended variables

We recommend at a minimum, to use the LunaPlaygroundField attribute for:

  • Call to action colors
  • Call to action text values.
  • In-ad messages such as those found in end cards or tutorials.