Configure Game Variables

Luna Replay allows you to capture a single piece of gameplay footage, and create unlimited variations by changing anything visual within the game without needing to re-record footage.

When preparing your game in Unity, you are able to apply the LunaPlaygroundField 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.

This attribute will then surface these game variables when creating your replays, either in the Unity editor, or Luna Playground.

Please keep in mind that changing gameplay values which impact the timeline of events (i.e. speeds, physics, sizes) may impact the output, and cause discrepancies between the original capture. We recommend only changing variables which are visual and do not alter the game flow.

Steps

  1. Apply the Luna LunaPlaygroundField attribute to your game variables
  2. Implement the ISerializationCallbackReceiver interface on a MonoBehaviour or 'ScriptableObject' where the variables are declared

Attribute Type

LunaPlaygroundField

This Luna attribute should be used for the scriptable game objects you wish to edit from Luna Playground.

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

Implementation

When applying the LunaPlaygroundField attribute, you may use the #if UNITY_LUNA_FIELD … #endif clause to avoid compilation errors in the editor.

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

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

  • Field title: The name of the field in Playground i.e. "Tutorial Message"
  • Field order: The order of the field in Playground
  • Field section: The name of the group to which the field belongs i.e. "Tutorial"

Example

public class PlaygroundExample : MonoBehaviour, ISerializationCallbackReceiver {
[Header("Video Settings")]
[SerializeField]
[LunaPlaygroundField("Color of the player", 0, "Player Controls")]
private Color playerColor = Color.blue;
[SerializeField]
[LunaPlaygroundField("Enable UI", 0, "UI Controls")]
private bool enableUI;
//...
public void OnBeforeSerialize() {
}
public void OnAfterDeserialize() {
}
}

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, making it easier to organise your fields in Luna Playground.

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

For example:

[LunaPlaygroundSection("Player Controls", 0)]
public class Player : MonoBehaviour, ISerializationCallbackReceiver {
[SerializeField]
[LunaPlaygroundField("Color of the player", 0)]
private Color playerColor = Color.blue;