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 Creative Suite. These fields should be used within your game code so that the default values are overridden when the game is initialised.
This attribute will then surface these game variables when creating your replays, either in the Unity editor, or Creative Suite.
Steps
- Include
using Luna.Replay.Playground;
in the script(s) you wish to configure variables in. - Apply the Luna
LunaPlaygroundField
attribute to your game variables - Implement the
ISerializationCallbackReceiver
interface on aMonoBehaviour
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 Creative Suite.
- Supported Types
- String
- Integer
- Float
- Color
- Vector2
- Vector3
- Vector4
- Enums
- Bool
Implementation
For each Creative Suite Field, you can specify the title, order and section.
[LunaPlaygroundField("Field title", 0, "Group title")]
- Field title: The name of the field in Creative Suite i.e. "Tutorial Message"
- Field order: The order of the field in Creative Suite
- Field section: The name of the group to which the field belongs i.e. "Tutorial"
Example
using Luna.Replay.Playground;
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() {
}
}
Creative Suite Sections
The LunaPlaygroundSection
attribute can be applied to a class in order to add include all supported fields as Creative Suite Attributes.
For example:
[LunaPlaygroundSection("Player Controls", 0)]
public class Player : MonoBehaviour, ISerializationCallbackReceiver {
private Color playerColor = Color.blue;
...
}
The result will mean that playerColor
is exposed as a LunaPlaygroundField.