Skip to content

Actions and Variables

Alex Lementuev edited this page Jan 18, 2017 · 12 revisions

Table of Contents

Actions

'Actions' provide a quick and easy way to execute arbitrary methods from Lunar Mobile Console.
quick actions

Using actions API

You can register/unregister actions using the following API calls:

  • LunarConsole.RegisterAction(name, callback) - registers action with name and callback
  • LunarConsole.UnregisterAction(callback) - unregisters action with specified callback
  • LunarConsole.UnregisterAction(name) - unregisters action with specified name
  • LunarConsole.UnregisterAllActions(target) - unregisters ALL actions with specified target

Example:

using UnityEngine;
using LunarConsolePlugin;

public class TestActions : MonoBehaviour
{
    void Start()
    {
        LunarConsole.RegisterAction("Action-1", Action1);
        LunarConsole.RegisterAction("Action-2", Action2);
        LunarConsole.RegisterAction("Action-3", Action3);
    }

    void OnDestroy()
    {
        LunarConsole.UnregisterAllActions(this); // don't forget to unregister!
    }

    void Action1()
    {
        ...
    }

    void Action2()
    {
        ...
    }

    void Action3()
    {
        ...
    }
}

Using LunarConsoleActions component

  • Select a GameObject from your scene and add Lunar Console Actions component to it:
- Use ```Add``` and ```Remove``` buttons to register and unregister actions: - Use ```Dont Destroy On Load``` checkbox to keep actions between scene loading

Variables

TBD

Sidebar

Clone this wiki locally